CopperSpice API
1.9.2
|
Single line text edit widget. More...
Public Types | |
enum | ActionPosition |
enum | EchoMode |
Public Types inherited from QWidget | |
enum | RenderFlag |
Public Types inherited from QPaintDevice | |
enum | PaintDeviceMetric |
Public Signals | |
void | cursorPositionChanged (int oldValue, int newValue) |
void | editingFinished () |
void | returnPressed () |
void | selectionChanged () |
void | textChanged (const QString &newText) |
void | textEdited (const QString &newText) |
Public Signals inherited from QWidget | |
void | customContextMenuRequested (const QPoint &pos) |
void | windowIconChanged (const QIcon &icon) |
void | windowIconTextChanged (const QString &iconText) |
void | windowTitleChanged (const QString &title) |
Public Signals inherited from QObject | |
void | destroyed (QObject *obj=nullptr) |
void | objectNameChanged (const QString &objectName) |
Public Slots | |
void | clear () |
void | copy () |
void | cut () |
void | paste () |
void | redo () |
void | selectAll () |
void | setText (const QString &str) |
void | undo () |
Public Slots inherited from QWidget | |
bool | close () |
void | hide () |
void | lower () |
void | raise () |
void | repaint () |
void | setDisabled (bool disable) |
void | setEnabled (bool enable) |
void | setFocus () |
void | setHidden (bool hidden) |
void | setStyleSheet (const QString &styleSheet) |
virtual void | setVisible (bool visible) |
void | setWindowModified (bool modified) |
void | setWindowTitle (const QString &title) |
void | show () |
void | showFullScreen () |
void | showMaximized () |
void | showMinimized () |
void | showNormal () |
void | update () |
Public Slots inherited from QObject | |
void | deleteLater () |
Public Methods | |
QLineEdit (const QString &contents, QWidget *parent=nullptr) | |
QLineEdit (QWidget *parent=nullptr) | |
~QLineEdit () | |
QAction * | addAction (const QIcon &icon, ActionPosition position) |
void | addAction (QAction *action) |
void | addAction (QAction *action, ActionPosition position) |
Qt::Alignment | alignment () const |
void | backspace () |
QCompleter * | completer () const |
QMenu * | createStandardContextMenu () |
void | cursorBackward (bool mark, int steps=1) |
void | cursorForward (bool mark, int steps=1) |
Qt::CursorMoveStyle | cursorMoveStyle () const |
int | cursorPosition () const |
int | cursorPositionAt (const QPoint &pos) |
void | cursorWordBackward (bool mark) |
void | cursorWordForward (bool mark) |
void | del () |
void | deselect () |
QString | displayText () const |
bool | dragEnabled () const |
EchoMode | echoMode () const |
void | end (bool mark) |
bool | event (QEvent *event) override |
void | getTextMargins (int *left, int *top, int *right, int *bottom) const |
bool | hasAcceptableInput () const |
bool | hasFrame () const |
bool | hasSelectedText () const |
void | home (bool mark) |
QString | inputMask () const |
QVariant | inputMethodQuery (Qt::InputMethodQuery query) const override |
void | insert (const QString &newText) |
bool | isClearButtonEnabled () const |
bool | isModified () const |
bool | isReadOnly () const |
bool | isRedoAvailable () const |
bool | isUndoAvailable () const |
int | maxLength () const |
QSize | minimumSizeHint () const override |
QString | placeholderText () const |
QString | selectedText () const |
int | selectionStart () const |
void | setAlignment (Qt::Alignment flag) |
void | setClearButtonEnabled (bool enable) |
void | setCompleter (QCompleter *completer) |
void | setCursorMoveStyle (Qt::CursorMoveStyle style) |
void | setCursorPosition (int) |
void | setDragEnabled (bool enable) |
void | setEchoMode (EchoMode) |
void | setFrame (bool) |
void | setInputMask (const QString &inputMask) |
void | setMaxLength (int) |
void | setModified (bool) |
void | setPlaceholderText (const QString &) |
void | setReadOnly (bool) |
void | setSelection (int start, int length) |
void | setTextMargins (const QMargins &margins) |
void | setTextMargins (int left, int top, int right, int bottom) |
void | setValidator (const QValidator *validator) |
QSize | sizeHint () const override |
QString | text () const |
QMargins | textMargins () const |
const QValidator * | validator () const |
Public Methods inherited from QWidget | |
QWidget (QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag) | |
~QWidget () | |
bool | acceptDrops () const |
QString | accessibleDescription () const |
QString | accessibleName () const |
QList< QAction * > | actions () const |
void | activateWindow () |
void | addAction (QAction *action) |
void | addActions (const QList< QAction * > &actions) |
void | adjustSize () |
bool | autoFillBackground () const |
QPalette::ColorRole | backgroundRole () const |
QBackingStore * | backingStore () const |
QSize | baseSize () const |
QWidget * | childAt (const QPoint &position) const |
QWidget * | childAt (int x, int y) const |
QRect | childrenRect () const |
QRegion | childrenRegion () const |
void | clearFocus () |
void | clearMask () |
QMargins | contentsMargins () const |
QRect | contentsRect () const |
Qt::ContextMenuPolicy | contextMenuPolicy () const |
QCursor | cursor () const |
WId | effectiveWinId () const |
void | ensurePolished () const |
Qt::FocusPolicy | focusPolicy () const |
QWidget * | focusProxy () const |
QWidget * | focusWidget () const |
const QFont & | font () const |
QFontInfo | fontInfo () const |
QFontMetrics | fontMetrics () const |
QPalette::ColorRole | foregroundRole () const |
QRect | frameGeometry () const |
QSize | frameSize () const |
const QRect & | geometry () const |
void | getContentsMargins (int *left, int *top, int *right, int *bottom) const |
QPixmap | grab (const QRect &rectangle=QRect (QPoint (0, 0), QSize (-1,-1))) |
void | grabGesture (Qt::GestureType gestureType, Qt::GestureFlags flags=Qt::GestureFlags ()) |
void | grabKeyboard () |
void | grabMouse () |
void | grabMouse (const QCursor &cursor) |
int | grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut) |
QGraphicsEffect * | graphicsEffect () const |
QGraphicsProxyWidget * | graphicsProxyWidget () const |
bool | hasEditFocus () const |
bool | hasFocus () const |
virtual bool | hasHeightForWidth () const |
bool | hasMouseTracking () const |
int | height () const |
virtual int | heightForWidth (int width) const |
Qt::InputMethodHints | inputMethodHints () const |
void | insertAction (QAction *before, QAction *action) |
void | insertActions (QAction *before, QList< QAction * > actions) |
bool | isActiveWindow () const |
bool | isAncestorOf (const QWidget *child) const |
bool | isEnabled () const |
bool | isEnabledTo (const QWidget *parent) const |
bool | isEnabledToTLW () const |
bool | isFullScreen () const |
bool | isHidden () const |
bool | isMaximized () const |
bool | isMinimized () const |
bool | isModal () const |
bool | isTopLevel () const |
bool | isVisible () const |
bool | isVisibleTo (const QWidget *parent) const |
bool | isWindow () const |
bool | isWindowModified () const |
QLayout * | layout () const |
Qt::LayoutDirection | layoutDirection () const |
QLocale | locale () const |
QPoint | mapFrom (const QWidget *parent, const QPoint &pos) const |
QPoint | mapFromGlobal (const QPoint &pos) const |
QPoint | mapFromParent (const QPoint &pos) const |
QPoint | mapTo (const QWidget *parent, const QPoint &pos) const |
QPoint | mapToGlobal (const QPoint &pos) const |
QPoint | mapToParent (const QPoint &pos) const |
QRegion | mask () const |
int | maximumHeight () const |
QSize | maximumSize () const |
int | maximumWidth () const |
int | minimumHeight () const |
QSize | minimumSize () const |
int | minimumWidth () const |
void | move (const QPoint &point) |
void | move (int x, int y) |
QWidget * | nativeParentWidget () const |
QWidget * | nextInFocusChain () const |
QRect | normalGeometry () const |
void | overrideWindowFlags (Qt::WindowFlags flags) |
QPaintEngine * | paintEngine () const override |
const QPalette & | palette () const |
QWidget * | parentWidget () const |
QPoint | pos () const |
QWidget * | previousInFocusChain () const |
QRect | rect () const |
void | releaseKeyboard () |
void | releaseMouse () |
void | releaseShortcut (int id) |
void | removeAction (QAction *action) |
void | render (QPaintDevice *target, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren)) |
void | render (QPainter *painter, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren)) |
void | repaint (const QRect &rect) |
void | repaint (const QRegion ®ion) |
void | repaint (int x, int y, int w, int h) |
void | resize (const QSize &size) |
void | resize (int w, int h) |
bool | restoreGeometry (const QByteArray &geometry) |
QByteArray | saveGeometry () const |
void | scroll (int dx, int dy) |
void | scroll (int dx, int dy, const QRect &rect) |
void | setAcceptDrops (bool on) |
void | setAccessibleDescription (const QString &description) |
void | setAccessibleName (const QString &name) |
void | setAttribute (Qt::WidgetAttribute attribute, bool enable=true) |
void | setAutoFillBackground (bool enable) |
void | setBackgroundRole (QPalette::ColorRole role) |
void | setBaseSize (const QSize &size) |
void | setBaseSize (int basew, int baseh) |
void | setContentsMargins (const QMargins &margins) |
void | setContentsMargins (int left, int top, int right, int bottom) |
void | setContextMenuPolicy (Qt::ContextMenuPolicy policy) |
void | setCursor (const QCursor &cursor) |
void | setEditFocus (bool enable) |
void | setFixedHeight (int h) |
void | setFixedSize (const QSize &size) |
void | setFixedSize (int w, int h) |
void | setFixedWidth (int w) |
void | setFocus (Qt::FocusReason reason) |
void | setFocusPolicy (Qt::FocusPolicy policy) |
void | setFocusProxy (QWidget *widget) |
void | setFont (const QFont &font) |
void | setForegroundRole (QPalette::ColorRole role) |
void | setGeometry (const QRect &rect) |
void | setGeometry (int x, int y, int w, int h) |
void | setGraphicsEffect (QGraphicsEffect *effect) |
void | setInputMethodHints (Qt::InputMethodHints hints) |
void | setLayout (QLayout *layout) |
void | setLayoutDirection (Qt::LayoutDirection direction) |
void | setLocale (const QLocale &locale) |
void | setMask (const QBitmap &bitmap) |
void | setMask (const QRegion ®ion) |
void | setMaximumHeight (int maxh) |
void | setMaximumSize (const QSize &size) |
void | setMaximumSize (int maxw, int maxh) |
void | setMaximumWidth (int maxw) |
void | setMinimumHeight (int minh) |
void | setMinimumSize (const QSize &size) |
void | setMinimumSize (int minw, int minh) |
void | setMinimumWidth (int minw) |
void | setMouseTracking (bool enable) |
void | setPalette (const QPalette &palette) |
void | setParent (QWidget *parent) |
void | setParent (QWidget *parent, Qt::WindowFlags flags) |
void | setShortcutAutoRepeat (int id, bool enable=true) |
void | setShortcutEnabled (int id, bool enable=true) |
void | setSizeIncrement (const QSize &size) |
void | setSizeIncrement (int w, int h) |
void | setSizePolicy (QSizePolicy policy) |
void | setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical) |
void | setStatusTip (const QString &data) |
void | setStyle (QStyle *style) |
void | setToolTip (const QString &data) |
void | setToolTipDuration (int msec) |
void | setUpdatesEnabled (bool enable) |
void | setWhatsThis (const QString &str) |
void | setWindowFilePath (const QString &filePath) |
void | setWindowFlags (Qt::WindowFlags flags) |
void | setWindowIcon (const QIcon &icon) |
void | setWindowModality (Qt::WindowModality windowModality) |
void | setWindowOpacity (qreal level) |
void | setWindowRole (const QString &role) |
void | setWindowState (Qt::WindowStates windowState) |
QSize | size () const |
QSize | sizeIncrement () const |
QSizePolicy | sizePolicy () const |
void | stackUnder (QWidget *widget) |
QString | statusTip () const |
QStyle * | style () const |
QString | styleSheet () const |
bool | testAttribute (Qt::WidgetAttribute attribute) const |
QString | toolTip () const |
int | toolTipDuration () const |
QWidget * | topLevelWidget () const |
bool | underMouse () const |
void | ungrabGesture (Qt::GestureType gestureType) |
void | unsetCursor () |
void | unsetLayoutDirection () |
void | unsetLocale () |
void | update (const QRect &rect) |
void | update (const QRegion ®ion) |
void | update (int x, int y, int w, int h) |
void | updateGeometry () |
bool | updatesEnabled () const |
QRegion | visibleRegion () const |
QString | whatsThis () const |
int | width () const |
QWidget * | window () const |
QString | windowFilePath () const |
Qt::WindowFlags | windowFlags () const |
QWindow * | windowHandle () const |
QIcon | windowIcon () const |
Qt::WindowModality | windowModality () const |
qreal | windowOpacity () const |
QString | windowRole () const |
Qt::WindowStates | windowState () const |
QString | windowTitle () const |
Qt::WindowType | windowType () const |
WId | winId () const |
int | x () const |
int | y () const |
Public Methods inherited from QObject | |
QObject (QObject *parent=nullptr) | |
~QObject () | |
bool | blockSignals (bool block) |
const QList< QObject * > & | children () const |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QString > | dynamicPropertyNames () const |
virtual bool | event (QEvent *event) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
template<typename T > | |
T | findChild (const QString &childName=QString ()) const |
template<class T > | |
QList< T > | findChildren (const QRegularExpression ®Exp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
template<class T > | |
QList< T > | findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
bool | inherits (const QString &className) const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const |
bool | isWindowType () const |
void | killTimer (int id) |
const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const |
QObject * | parent () const |
template<class T = QVariant> | |
T | property (const QString &name) const |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const QString &name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
QThread * | thread () const |
Public Methods inherited from QPaintDevice | |
virtual | ~QPaintDevice () |
int | colorCount () const |
int | depth () const |
int | devicePixelRatio () const |
qreal | devicePixelRatioF () const |
int | height () const |
int | heightMM () const |
int | logicalDpiX () const |
int | logicalDpiY () const |
bool | paintingActive () const |
int | physicalDpiX () const |
int | physicalDpiY () const |
int | width () const |
int | widthMM () const |
Protected Methods | |
void | changeEvent (QEvent *event) override |
void | contextMenuEvent (QContextMenuEvent *event) override |
QRect | cursorRect () const |
void | dragEnterEvent (QDragEnterEvent *event) override |
void | dragLeaveEvent (QDragLeaveEvent *event) override |
void | dragMoveEvent (QDragMoveEvent *event) override |
void | dropEvent (QDropEvent *event) override |
void | focusInEvent (QFocusEvent *event) override |
void | focusOutEvent (QFocusEvent *event) override |
void | initStyleOption (QStyleOptionFrame *option) const |
void | inputMethodEvent (QInputMethodEvent *event) override |
void | keyPressEvent (QKeyEvent *event) override |
void | mouseDoubleClickEvent (QMouseEvent *event) override |
void | mouseMoveEvent (QMouseEvent *event) override |
void | mousePressEvent (QMouseEvent *event) override |
void | mouseReleaseEvent (QMouseEvent *event) override |
void | paintEvent (QPaintEvent *event) override |
Protected Methods inherited from QWidget | |
virtual void | actionEvent (QActionEvent *event) |
virtual void | closeEvent (QCloseEvent *event) |
void | create (WId window=0, bool initializeWindow=true, bool destroyOldWindow=true) |
void | destroy (bool destroyWindow=true, bool destroySubWindows=true) |
virtual void | enterEvent (QEvent *event) |
bool | event (QEvent *event) override |
bool | focusNextChild () |
virtual bool | focusNextPrevChild (bool next) |
bool | focusPreviousChild () |
virtual void | hideEvent (QHideEvent *event) |
void | initPainter (QPainter *painter) const override |
virtual void | keyReleaseEvent (QKeyEvent *event) |
virtual void | leaveEvent (QEvent *event) |
int | metric (PaintDeviceMetric metric) const override |
virtual void | moveEvent (QMoveEvent *event) |
virtual bool | nativeEvent (const QByteArray &eventType, void *message, long *result) |
virtual void | resizeEvent (QResizeEvent *event) |
virtual void | showEvent (QShowEvent *event) |
virtual void | tabletEvent (QTabletEvent *event) |
virtual void | wheelEvent (QWheelEvent *event) |
Protected Methods inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signalMethod) const |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signalMethod) const |
bool | isSignalConnected (const QMetaMethod &signalMethod) const |
int | receivers (const QString &signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Protected Methods inherited from QPaintDevice | |
QPaintDevice () | |
Friends | |
class | QAbstractSpinBox |
class | QDateTimeEdit |
Additional Inherited Members | |
Public Typedefs inherited from QWidget | |
using | RenderFlags = QFlags< RenderFlag > |
Static Public Methods inherited from QWidget | |
static QWidget * | createWindowContainer (QWindow *window, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag) |
static QWidget * | find (WId id) |
static QWidget * | keyboardGrabber () |
static QWidget * | mouseGrabber () |
static void | setTabOrder (QWidget *firstWidget, QWidget *secondWidget) |
Static Public Methods inherited from QObject | |
static bool | connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ()) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...)) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod) |
static QMetaObject & | staticMetaObject () |
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
Protected Slots inherited from QWidget | |
void | updateMicroFocus () |
Related Functions inherited from QWidget | |
QWidgetList | |
WId | |
Related Functions inherited from QObject | |
T | qobject_cast (QObject *object) |
QObjectList | |
The QLineEdit widget is a single line text edit widget. A line edit allows the user to edit plain text with standard editing operations like undo, redo, cut, copy, and paste. The QTextEdit class is very similar to this one however it allows multi line and rich text editing.
When the text changes either by calling setText() or the user typing, the textChanged() signal will be emitted. When the cursor is moved the cursorPositionChanged() signal is emitted and when the Return or Enter key are pressed the returnPressed() signal is emitted.
When editing is finished, either because the line edit has lost focus or Return/Enter was pressed, then the editingFinished() signal will be emitted. If there is a validator set on the line edit these signals will only be emitted if the validator returns QValidator::Acceptable.
The default shortcuts or key bindings are described below. The line edit widget also provides a context menu which contains some of these editing options. Any other key sequence that represents a valid character will cause the character to be inserted into the line edit.
Keypress | Action |
---|---|
Left Arrow | Moves the cursor one character to the left. |
Shift+Left Arrow | Moves and selects text one character to the left. |
Right Arrow | Moves the cursor one character to the right. |
Shift+Right Arrow | Moves and selects text one character to the right. |
Home | Moves the cursor to the beginning of the line. |
End | Moves the cursor to the end of the line. |
Backspace | Deletes the character to the left of the cursor. |
Ctrl+Backspace | Deletes the word to the left of the cursor. |
Delete | Deletes the character to the right of the cursor. |
Ctrl+Delete | Deletes the word to the right of the cursor. |
Ctrl+A | Select all. |
Ctrl+C | Copies the selected text to the clipboard. |
Ctrl+Insert | Copies the selected text to the clipboard. |
Ctrl+K | Deletes to the end of the line. |
Ctrl+V | Pastes the clipboard text into line edit. |
Shift+Insert | Pastes the clipboard text into line edit. |
Ctrl+X | Deletes the selected text and copies it to the clipboard. |
Shift+Delete | Deletes the selected text and copies it to the clipboard. |
Ctrl+Z | Undoes the last operation. |
Ctrl+Y | Redoes the last undone operation. |
Line edit shown in the Windows XP widget style. | |
Line edit shown in the Mac OS X widget style. | |
Line edit shown in the Fusion widget style. |
This enum describes how a line edit should display the action widgets.
Constant | Value | Description |
---|---|---|
QLineEdit::LeadingPosition | 0 | Widget is displayed to the left of the text when using layout direction Qt::LeftToRight or to the right when using Qt::RightToLeft, respectively. |
QLineEdit::TrailingPosition | 1 | Widget is displayed to the right of the text when using layout direction Qt::LeftToRight or to the left when using Qt::RightToLeft, respectively. |
enum QLineEdit::EchoMode |
This enum type describes how a line edit should display its contents.
Constant | Value | Description |
---|---|---|
QLineEdit::Normal | 0 | Display characters as they are entered, this is the default. |
QLineEdit::NoEcho | 1 | Do not display anything. This may be appropriate for passwords where even the length of the password should be kept secret. |
QLineEdit::Password | 2 | Display asterisks instead of the characters actually entered. |
QLineEdit::PasswordEchoOnEdit | 3 | Display characters as they are entered while editing otherwise display asterisks. |
|
explicit |
Constructs a line edit with no text. The parent argument is sent to the QWidget constructor. The maximum text length is set to 32767 characters.
Constructs a line edit containing the text contents. The parent and argument is sent to the QWidget constructor. The cursor position is set to the end of the line and the maximum text length to 32767 characters.
QLineEdit::~QLineEdit | ( | ) |
Destroys the line edit.
QAction * QLineEdit::addAction | ( | const QIcon & | icon, |
ActionPosition | position | ||
) |
Adds the icon to the list of existing actions available for this line edit. The location of the given action is added at the specified position.
|
using |
Appends action to the list of existing actions available for this widget. A QAction list is typically used to create a context QMenu, however it can be represented in different ways depending on the widget.
A QWidget should only have one of each action. Adding an action which already exists will not cause the same action to be in the widget multiple times. The ownership of action is not transferred to this QWidget.
void QLineEdit::addAction | ( | QAction * | action, |
ActionPosition | position | ||
) |
Add the action to the list of existing actions available for this line edit. The location of the given action is added at the specified position.
Qt::Alignment QLineEdit::alignment | ( | ) | const |
Returns the value of the alignment property.
void QLineEdit::backspace | ( | ) |
If no text is selected, this method deletes the character to the left of the text cursor and moves the cursor one position to the left. If any text is selected, the cursor is moved to the beginning of the selected text and the selected text is deleted.
|
overrideprotectedvirtual |
Reimplemented from QWidget::changeEvent()
QCompleter * QLineEdit::completer | ( | ) | const |
Returns the current QCompleter.
|
overrideprotectedvirtual |
Shows a context menu. The event parameter is used to obtain the position where the mouse cursor was when the event was generated.
If you do not want the line edit to have a context menu, you can set its contextMenuPolicy to Qt::NoContextMenu. If you want to customize the context menu, reimplement this method. If you want to extend the standard context menu, reimplement this function, call createStandardContextMenu() and extend the menu returned.
Reimplemented from QWidget::contextMenuEvent()
|
slot |
Copies the selected text to the clipboard when the echoMode() is set to EchoMode::Normal.
QMenu * QLineEdit::createStandardContextMenu | ( | ) |
This method creates the standard context menu which is shown when the user clicks on the line edit with the right mouse button. It is called from the default contextMenuEvent() handler. The popup menu's ownership is transferred to the caller.
void QLineEdit::cursorBackward | ( | bool | mark, |
int | steps = 1 |
||
) |
Moves the cursor back steps characters. If mark is true each character moved over is added to the selection. If mark is false the selection is cleared.
void QLineEdit::cursorForward | ( | bool | mark, |
int | steps = 1 |
||
) |
Moves the cursor forward steps characters. If mark is true each character moved over is added to the selection. If mark is false the selection is cleared.
Qt::CursorMoveStyle QLineEdit::cursorMoveStyle | ( | ) | const |
Returns the value of the cursorMoveStyle property.
int QLineEdit::cursorPosition | ( | ) | const |
Returns the value of the cursorPosition property.
int QLineEdit::cursorPositionAt | ( | const QPoint & | pos | ) |
Returns the cursor position under the point pos.
|
signal |
This signal is emitted whenever the cursor moves. The previous position is given by oldValue and the new position by newValue.
|
protected |
Returns a rectangle that includes the line edit cursor.
void QLineEdit::cursorWordBackward | ( | bool | mark | ) |
Moves the cursor one word backward. If mark is true the word is also selected.
void QLineEdit::cursorWordForward | ( | bool | mark | ) |
Moves the cursor one word forward. If mark is true the word is also selected.
|
slot |
Copies the selected text to the clipboard and deletes it when echoMode() is set to EchoMode::Normal. If the current validator disallows deleting the selected text, cut() will copy without deleting.
void QLineEdit::del | ( | ) |
If no text is selected, deletes the character to the right of the text cursor. If any text is selected, the cursor is moved to the beginning of the selected text and the selected text is deleted.
void QLineEdit::deselect | ( | ) |
Deselects any selected text.
QString QLineEdit::displayText | ( | ) | const |
Returns the value of the displayText property.
bool QLineEdit::dragEnabled | ( | ) | const |
Returns the value of the property.
|
overrideprotectedvirtual |
Reimplemented from QWidget::dragEnterEvent()
|
overrideprotectedvirtual |
Reimplemented from QWidget::dragLeaveEvent()
|
overrideprotectedvirtual |
Reimplemented from QWidget::dragMoveEvent()
|
overrideprotectedvirtual |
Reimplemented from QWidget::dropEvent()
|
signal |
This signal is emitted when the Return or Enter key is pressed or the line edit loses focus. If there is a validator() or inputMask() set on the line edit and enter/return is pressed, the editingFinished() signal will only be emitted if the input matches the inputMask() and the validator() returns QValidator::Acceptable.
void QLineEdit::end | ( | bool | mark | ) |
Moves the text cursor to the end of the line unless it is already there. If mark is true text is selected towards the last position, otherwise any selected text is unselected if the cursor is moved.
|
override |
Reimplemented from QWidget::event()
|
overrideprotectedvirtual |
Reimplemented from QWidget::focusInEvent()
|
overrideprotectedvirtual |
Reimplemented from QWidget::focusOutEvent()
void QLineEdit::getTextMargins | ( | int * | left, |
int * | top, | ||
int * | right, | ||
int * | bottom | ||
) | const |
Returns the widget's text margins for left, top, right, and bottom.
bool QLineEdit::hasAcceptableInput | ( | ) | const |
Returns the value of the acceptableInput property.
bool QLineEdit::hasFrame | ( | ) | const |
Returns the value of the frame property.
bool QLineEdit::hasSelectedText | ( | ) | const |
Returns the value of the hasSelectedText property.
void QLineEdit::home | ( | bool | mark | ) |
Moves the text cursor to the beginning of the line unless it is already there. If mark is true, text is selected towards the first position, otherwise any selected text is unselected if the cursor is moved.
|
protected |
Initialize option with the values from this QLineEdit. This method is useful for subclasses when they need a QStyleOptionFrame but do not want to fill in all the information themselves.
QString QLineEdit::inputMask | ( | ) | const |
Returns the value for the inputMask property.
|
overrideprotectedvirtual |
Reimplemented from QWidget::inputMethodEvent()
|
overridevirtual |
Reimplemented from QWidget::inputMethodQuery()
void QLineEdit::insert | ( | const QString & | newText | ) |
bool QLineEdit::isClearButtonEnabled | ( | ) | const |
Returns true if the clearButtonEnabled property is enabled, otherwise returns false.
bool QLineEdit::isModified | ( | ) | const |
Returns the value of the modified property.
bool QLineEdit::isReadOnly | ( | ) | const |
Returns the value of the readOnly property.
bool QLineEdit::isRedoAvailable | ( | ) | const |
Returns the value of the redoAvailable property.
bool QLineEdit::isUndoAvailable | ( | ) | const |
Returns the value of the undoAvailable property.
|
overrideprotectedvirtual |
Converts the given key press event into a line edit action. If Return or Enter is pressed and the current text is valid (or can be made valid by the validator), the signal returnPressed() is emitted.
The default key bindings are listed in the class detailed description.
Reimplemented from QWidget::keyPressEvent()
int QLineEdit::maxLength | ( | ) | const |
Returns the value of the maxLength property.
|
overridevirtual |
Returns a minimum size for the line edit. The width returned is enough for at least one character.
Reimplemented from QWidget::minimumSizeHint()
|
overrideprotectedvirtual |
Reimplemented from QWidget::mouseDoubleClickEvent()
|
overrideprotectedvirtual |
Reimplemented from QWidget::mouseMoveEvent()
|
overrideprotectedvirtual |
Reimplemented from QWidget::mousePressEvent()
|
overrideprotectedvirtual |
Reimplemented from QWidget::mouseReleaseEvent()
|
overrideprotectedvirtual |
Reimplemented from QWidget::paintEvent()
|
slot |
QString QLineEdit::placeholderText | ( | ) | const |
Returns the value of the placeholderText property.
|
slot |
Redoes the last operation if redo is available.
|
signal |
This signal is emitted when the Return or Enter key is pressed. If there is a validator() or inputMask() set on the line edit, the returnPressed() signal will only be emitted if the input matches the inputMask() and the validator() returns QValidator::Acceptable.
|
slot |
Selects all the text and moves the cursor to the end. This is useful when a default value has been inserted. If the user types before clicking on the widget the default selected text will be deleted.
QString QLineEdit::selectedText | ( | ) | const |
Returns the value of the property.
|
signal |
This signal is emitted when the selection changes.
int QLineEdit::selectionStart | ( | ) | const |
Returns the index of the first selected character in the line edit or -1 if no text is selected.
void QLineEdit::setAlignment | ( | Qt::Alignment | flag | ) |
Sets the value of the alignment property.
void QLineEdit::setClearButtonEnabled | ( | bool | enable | ) |
Sets the value of the clearButtonEnabled property.
void QLineEdit::setCompleter | ( | QCompleter * | completer | ) |
Sets this line edit to provide auto completion using completer. The completion mode is set using QCompleter::setCompletionMode(). If the value for completer is a nullptr this method removes the current QCompleter.
To use a QCompleter with a QValidator or QLineEdit::inputMask, you need to ensure that the model provided to QCompleter contains valid entries. You can use the QSortFilterProxyModel to ensure that the QCompleter's model contains only valid entries.
void QLineEdit::setCursorMoveStyle | ( | Qt::CursorMoveStyle | style | ) |
Sets the value of the cursorMoveStyle property to style.
void QLineEdit::setCursorPosition | ( | int | ) |
Sets the value of the cursorPosition property.
void QLineEdit::setDragEnabled | ( | bool | enable | ) |
Sets the value of the dragEnabled property to enable.
void QLineEdit::setFrame | ( | bool | ) |
Sets the value of the frame property.
void QLineEdit::setInputMask | ( | const QString & | inputMask | ) |
Sets the inputMask property to inputMask. To unset the mask and return to normal QLineEdit operation pass an empty string or call this method with no arguments.
Refer to the inputMask property for examples.
void QLineEdit::setMaxLength | ( | int | ) |
Sets the value of the maxLength property.
void QLineEdit::setModified | ( | bool | ) |
Sets the value of the modified property.
void QLineEdit::setPlaceholderText | ( | const QString & | ) |
Sets the value of the placeholderText property.
void QLineEdit::setReadOnly | ( | bool | ) |
Sets the value of the readOnly property.
void QLineEdit::setSelection | ( | int | start, |
int | length | ||
) |
Selects text from position start and for length characters. Negative lengths are allowed.
|
slot |
Sets the value of the text property to str.
void QLineEdit::setTextMargins | ( | const QMargins & | margins | ) |
Sets the margins around the text inside the frame.
void QLineEdit::setTextMargins | ( | int | left, |
int | top, | ||
int | right, | ||
int | bottom | ||
) |
Sets the margins around the text inside the frame to have the sizes left, top, right, and bottom.
void QLineEdit::setValidator | ( | const QValidator * | validator | ) |
Sets this line edit to check input using validator. This allows setting constraints on the text which may be entered. If the value for validator is a nullptr the current input QValidator is removed. The initial setting is to have no input QValidator.
|
overridevirtual |
Returns a recommended size for the widget. The width returned, which is in pixels, is usually enough for about 15 to 20 characters.
Reimplemented from QWidget::sizeHint()
QString QLineEdit::text | ( | ) | const |
Returns the value of the text property.
|
signal |
This signal is emitted when the text changes. The newText argument is the new text. Unlike the textEdited() signal, this signal is emitted when the text is changed by the user typing or when the program calls setText().
|
signal |
This signal is emitted when the text is edited. The newText argument is the new text.
QMargins QLineEdit::textMargins | ( | ) | const |
Returns the text margins for the line edit widget.
|
slot |
Undoes the last operation if undo is available. Deselects any current selection and updates the selection start to the current cursor position.
const QValidator * QLineEdit::validator | ( | ) | const |
Returns a pointer to the current input validator or nullptr if no validator has been set.
|
This property holds whether the input satisfies the inputMask and the validator. By default this property is true.
Properties | Class Methods |
---|---|
read | hasAcceptableInput |
|
This property holds the alignment of the line edit. Both horizontal and vertical alignment is allowed here, Qt::AlignJustify will map to Qt::AlignLeft.
By default this property contains a combination of Qt::AlignLeft and Qt::AlignVCenter.
Properties | Class Methods |
---|---|
read | alignment |
write | setAlignment |
|
This property holds whether the line edit displays a clear button when it is not empty. If enabled the line edit displays a trailing clear button when it contains some text, otherwise the line edit does not show a clear button, which is the default.
Properties | Class Methods |
---|---|
read | isClearButtonEnabled |
write | setClearButtonEnabled |
|
This property holds the movement style of cursor in this line edit.
When this property is set to Qt::VisualMoveStyle, the line edit will use visual movement style. Pressing the left arrow key will always cause the cursor to move left, regardless of the text's writing direction. The same behavior applies to right arrow key.
When the property is Qt::LogicalMoveStyle (the default), within a LTR text block, increase cursor position when pressing left arrow key, decrease cursor position when pressing the right arrow key. If the text block is right to left, the opposite behavior applies.
Properties | Class Methods |
---|---|
read | cursorMoveStyle |
write | setCursorMoveStyle |
|
This property holds the current cursor position for this line edit. Setting the cursor position causes a repaint when appropriate.
By default this property contains a value of 0.
Properties | Class Methods |
---|---|
read | cursorPosition |
write | setCursorPosition |
|
This property holds the displayed text.
If echoMode is set to EchoMode::Normal displayText and text() will contain the same value. If EchoMode is set to EchoMode::Password or EchoMode::PasswordEchoOnEdit then displayText will contain a string of asterisks. If EchoMode is set to EchoMode::NoEcho then displayText contains an empty string.
By default this property contains an empty string.
Properties | Class Methods |
---|---|
read | displayText |
|
This property holds whether the line edit starts a drag if the user presses and moves the mouse on some selected text. Dragging is disabled by default.
Properties | Class Methods |
---|---|
read | dragEnabled |
write | setDragEnabled |
|
This property holds the echo mode for this line edit.
The echo mode determines how the text entered in the line edit is displayed (or echoed) to the user. The most common setting is EchoMode::Normal where the text entered by the user is displayed exactly as they typed it.
QLineEdit also supports modes that allow the entered text to be hidden. The widget's display and the ability to copy or drag the text is affected by this setting.
By default this property is set to EchoMode::Normal.
Properties | Class Methods |
---|---|
read | echoMode |
write | setEchoMode |
|
This property holds whether the line edit draws itself with a frame. If enabled (the default) the line edit draws itself inside a frame, otherwise the line edit draws itself without any frame.
Properties | Class Methods |
---|---|
read | hasFrame |
write | setFrame |
|
This property holds whether there is any text selected. Returns true if some or all of the text has been selected by the user, otherwise returns false.
By default this property is false.
Properties | Class Methods |
---|---|
read | hasSelectedText |
|
This property holds the value for the input mask. The table below shows the characters which can be used to define an input mask. A space means a character is permitted but not required.
Character | Description |
---|---|
A | ASCII alphabetic character required. A-Z, a-z. |
a | ASCII alphabetic character permitted but not required. |
N | ASCII alphanumeric character required. A-Z, a-z, 0-9. |
n | ASCII alphanumeric character permitted but not required. |
X | Any character required. |
x | Any character permitted but not required. |
9 | ASCII digit required. 0-9. |
0 | ASCII digit permitted but not required. |
D | ASCII digit required. 1-9. |
d | ASCII digit permitted but not required (1-9). |
# | ASCII digit or plus/minus sign permitted but not required. |
H | Hexadecimal character required. A-F, a-f, 0-9. |
h | Hexadecimal character permitted but not required. |
B | Binary character required. 0-1. |
b | Binary character permitted but not required. |
> | All following alphabetic characters are uppercased. |
< | All following alphabetic characters are lowercased. |
! | Switch off case conversion. |
\ | Use \ to escape the special characters listed above to use them as separators. |
The mask can end with a semicolon followed by one character. This character will be used instead of displaying a "space". The special blank characters are always removed from the text after editing.
Mask | Notes |
---|---|
000.000.000.000;_ | IP address, blanks are denoted with an underscore |
HH:HH:HH:HH:HH:HH;_ | MAC address, blanks are denoted with a pound sign |
0000-00-00 | ISO Date, blanks are denoted with a space |
>AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;# | License number, blanks are denoted with a dash and all alphabetic characters are converted to uppercase |
Properties | Class Methods |
---|---|
read | inputMask |
write | setInputMask |
|
This property holds the maximum permitted length of the text.
If the text is too long, it is truncated at the limit. If truncation occurs any selected text will be unselected, the cursor position is set to 0 and the first part of the string is shown. If the line edit has an input mask, the mask defines the maximum string length.
By default this property contains a value of 32767.
Properties | Class Methods |
---|---|
read | maxLength |
write | setMaxLength |
|
This property holds whether the line edit's contents has been modified by the user. The modified flag is never read by QLineEdit, it has a default value of false and is changed to true whenever the user changes the line edit's contents.
This is useful for things that need to provide a default value but do not start out knowing what the default should be (perhaps it depends on other fields on the form). Start the line edit without the best default, and when the default is known, if modified() returns false (the user has not entered any text), insert the default value.
Calling setText() resets the modified flag to false.
Properties | Class Methods |
---|---|
read | isModified |
write | setModified |
designable | true |
|
This property holds the line edit's placeholder text. Setting this property makes the line edit display a grayed-out placeholder text as long as the text() is empty and the widget does not have focus.
By default this property contains an empty string.
Properties | Class Methods |
---|---|
read | placeholderText |
write | setPlaceholderText |
|
This property holds whether the line edit is read only. In read only mode the user can still copy the text to the clipboard or drag and drop the text (if echoMode() is set to Normal), but can not edit it. QLineEdit does not show a cursor in read only mode.
By default this property is false.
Properties | Class Methods |
---|---|
read | isReadOnly |
write | setReadOnly |
|
This property holds whether redo is available. Redo becomes available once the user has performed one or more undo operations on text in the line edit.
By default this property is false.
Properties | Class Methods |
---|---|
read | isRedoAvailable |
|
This property holds the selected text. If there is no selected text this property's value is an empty string. By default this property contains an empty string.
Properties | Class Methods |
---|---|
read | selectedText |
|
This property holds the line edit's text.
Setting this property clears the selection, clears the undo/redo history, moves the cursor to the end of the line and resets the modified property to false. The text is not validated when inserted with setText(). The text is truncated to maxLength() length.
By default this property contains an empty string.
Properties | Class Methods |
---|---|
read | text |
write | setText |
notify | textChanged |
user | true |
|
This property holds whether undo is available. Undo becomes available once the user has modified the text in the line edit. By default this property is false.
Properties | Class Methods |
---|---|
read | isUndoAvailable |