QLineEdit Class Reference

The QLineEdit widget is a one-line text editor.

  1. #include <QLineEdit>

Inherits: QWidget.

Detailed Description

The QLineEdit widget is a one-line text editor.

A line edit allows the user to enter and edit a single line of plain text with a useful collection of editing functions, including undo and redo, cut and paste, and drag and drop.

By changing the echoMode() of a line edit, it can also be used as a "write-only" field, for inputs such as passwords.

The length of the text can be constrained to maxLength(). The text can be arbitrarily constrained using a validator() or an inputMask(), or both. When switching between a validator and an input mask on the same line edit, it is best to clear the validator or input mask to prevent undefined behavior.

A related class is QTextEdit which allows multi-line, rich text editing.

You can change the text with setText() or insert(). The text is retrieved with text(); the displayed text (which may be different, see EchoMode) is retrieved with displayText(). Text can be selected with setSelection() or selectAll(), and the selection can be cut(), copy()ied and paste()d. The text can be aligned with setAlignment().

When the text changes the textChanged() signal is emitted; when the text changes other than by calling setText() the textEdited() signal is emitted; when the cursor is moved the cursorPositionChanged() signal is emitted; and when the Return or Enter key is pressed the returnPressed() signal is emitted.

When editing is finished, either because the line edit lost focus or Return/Enter is pressed the editingFinished() signal is emitted.

Note that if there is a validator set on the line edit, the returnPressed()/editingFinished() signals will only be emitted if the validator returns QValidator::Acceptable.

By default, QLineEdits have a frame as specified by the Windows and Motif style guides; you can turn it off by calling setFrame(false).

The default key bindings are described below. The line edit also provides a context menu (usually invoked by a right mouse click) that presents some of these editing options.

KeypressAction
Left ArrowMoves the cursor one character to the left.
Shift+Left ArrowMoves and selects text one character to the left.
Right ArrowMoves the cursor one character to the right.
Shift+Right ArrowMoves and selects text one character to the right.
HomeMoves the cursor to the beginning of the line.
EndMoves the cursor to the end of the line.
BackspaceDeletes the character to the left of the cursor.
Ctrl+BackspaceDeletes the word to the left of the cursor.
DeleteDeletes the character to the right of the cursor.
Ctrl+DeleteDeletes the word to the right of the cursor.
Ctrl+ASelect all.
Ctrl+CCopies the selected text to the clipboard.
Ctrl+InsertCopies the selected text to the clipboard.
Ctrl+KDeletes to the end of the line.
Ctrl+VPastes the clipboard text into line edit.
Shift+InsertPastes the clipboard text into line edit.
Ctrl+XDeletes the selected text and copies it to the clipboard.
Shift+DeleteDeletes the selected text and copies it to the clipboard.
Ctrl+ZUndoes the last operation.
Ctrl+YRedoes the last undone operation.

Any other key sequence that represents a valid character, will cause the character to be inserted into the line edit.

Screenshot of a Macintosh style line edit

Screenshot of a Macintosh style line edit

A line edit shown in the Macintosh widget style.
Screenshot of a Windows XP style line edit

Screenshot of a Windows XP style line edit

A line edit shown in the Windows XP widget style.
Screenshot of a Plastique style line edit

Screenshot of a Plastique style line edit

A line edit shown in the Plastique widget style.

See also QTextEdit, QLabel, QComboBox, GUI Design Handbook: Field, Entry, and Line Edits Example.

Public Types

Toggle detailsenum QLineEdit::

EchoModeEchoMode { Normal , NoEcho , Password , PasswordEchoOnEdit 3 ...} { Normal , NoEcho , Password , PasswordEchoOnEdit 3 }

This enum type describes how a line edit should display its contents.

ConstantValueDescription
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.

See also setEchoMode() and echoMode().

Look up this member in the source code.

    Properties

    Toggle detailsacceptableInputacceptableInput : const bool

    This property holds whether the input satisfies the inputMask and the validator.

    By default, this property is true.

    See also setInputMask() and setValidator().

    Access functions:

    Look up this member in the source code.

    Toggle detailsalignmentalignment : Qt::Alignment

    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.

    See also Qt::Alignment.

    Access functions:

    Look up this member in the source code.

    Toggle detailscursorPositioncursorPosition : int

    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.

    Access functions:

    Look up this member in the source code.

    Toggle detailsdisplayTextdisplayText : const QString

    This property holds the displayed text

    If echoMode is Normal this returns the same as text(); if EchoMode is Password or PasswordEchoOnEdit it returns a string of asterisks text().length() characters long, e.g. "******"; if EchoMode is NoEcho returns an empty string, "".

    By default, this property contains an empty string.

    See also setEchoMode(), text(), and EchoMode.

    Access functions:

    Look up this member in the source code.

    Toggle detailsdragEnableddragEnabled : bool

    This property holds whether the lineedit starts a drag if the user presses and moves the mouse on some selected text

    Dragging is disabled by default.

    Access functions:

    Look up this member in the source code.

    Toggle detailsechoModeechoMode : EchoMode

    This property holds the line edit's echo mode

    The echo mode determines how the text entered in the line edit is displayed (or echoed) to the user.

    The most common setting is Normal, in which the text entered by the user is displayed verbatim, but QLineEdit also supports modes that allow the entered text to be suppressed or obscured: these include NoEcho, Password and PasswordEchoOnEdit.

    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 Normal.

    See also EchoMode and displayText().

    Access functions:

    Look up this member in the source code.

    Toggle detailsframeframe : bool

    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.

    Access functions:

    Look up this member in the source code.

    Toggle detailshasSelectedTexthasSelectedText : const bool

    This property holds whether there is any text selected

    hasSelectedText() returns true if some or all of the text has been selected by the user; otherwise returns false.

    By default, this property is false.

    See also selectedText().

    Access functions:

    Look up this member in the source code.

    Toggle detailsinputMaskinputMask : QString

    This property holds The validation input mask

    If no mask is set, inputMask() returns an empty string.

    Sets the QLineEdit's validation mask. Validators can be used instead of, or in conjunction with masks; see setValidator().

    Unset the mask and return to normal QLineEdit operation by passing an empty string ("") or just calling setInputMask() with no arguments.

    The table below shows the characters that can be used in an input mask. A space character, the default character for a blank, is needed for cases where a character is permitted but not required.

    CharacterMeaning
    AASCII alphabetic character required. A-Z, a-z.
    aASCII alphabetic character permitted but not required.
    NASCII alphanumeric character required. A-Z, a-z, 0-9.
    nASCII alphanumeric character permitted but not required.
    XAny character required.
    xAny character permitted but not required.
    9ASCII digit required. 0-9.
    0ASCII digit permitted but not required.
    DASCII digit required. 1-9.
    dASCII digit permitted but not required (1-9).
    #ASCII digit or plus/minus sign permitted but not required.
    HHexadecimal character required. A-F, a-f, 0-9.
    hHexadecimal character permitted but not required.
    BBinary character required. 0-1.
    bBinary 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 consists of a string of mask characters and separators, optionally followed by a semicolon and the character used for blanks. The blank characters are always removed from the text after editing.

    Examples:

    MaskNotes
    000.000.000.000;_IP address; blanks are _.
    HH:HH:HH:HH:HH:HH;_MAC address
    0000-00-00ISO Date; blanks are space
    >AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;#License number; blanks are - and all (alphabetic) characters are converted to uppercase.

    To get range control (e.g., for an IP address) use masks together with validators.

    See also maxLength.

    Access functions:

    Look up this member in the source code.

    Toggle detailsmaxLengthmaxLength : int

    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.

    See also inputMask.

    Access functions:

    Look up this member in the source code.

    Toggle detailsmodifiedmodified : bool

    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 hasn't entered any text), insert the default value.

    Calling setText() resets the modified flag to false.

    Access functions:

    Look up this member in the source code.

    Toggle detailsplaceholderTextplaceholderText : QString

    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 doesn't have focus.

    By default, this property contains an empty string.

    See also text().

    Access functions:

    Look up this member in the source code.

    Toggle detailsreadOnlyreadOnly : bool

    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 Normal), but cannot edit it.

    QLineEdit does not show a cursor in read-only mode.

    By default, this property is false.

    See also setEnabled().

    Access functions:

    Look up this member in the source code.

    Toggle detailsredoAvailableredoAvailable : const bool

    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.

    Access functions:

    Look up this member in the source code.

    Toggle detailsselectedTextselectedText : const QString

    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.

    See also hasSelectedText().

    Access functions:

    Look up this member in the source code.

    Toggle detailstexttext : QString

    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.

    See also insert() and clear().

    Access functions:

    Look up this member in the source code.

    Toggle detailsundoAvailableundoAvailable : const bool

    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.

    Access functions:

    Look up this member in the source code.

      Public Functions

      Toggle details QLineEdit

      QLineEditQLineEdit ( QWidget *parent=0 ) ( QWidget *parent=0 )

      Constructs a line edit with no text.

      The maximum text length is set to 32767 characters.

      The parent argument is sent to the QWidget constructor.

      See also setText() and setMaxLength().

      Look up this member in the source code.

      Toggle details QLineEdit

      QLineEditQLineEdit ( const QString &contents , QWidget *parent=0 ...) ( const QString &contents , QWidget *parent=0 )

      Constructs a line edit containing the text contents.

      The cursor position is set to the end of the line and the maximum text length to 32767 characters.

      The parent and argument is sent to the QWidget constructor.

      See also text() and setMaxLength().

      Look up this member in the source code.

      Toggle details QLineEdit

      ~QLineEdit~QLineEdit () ()

      Destroys the line edit.

      Look up this member in the source code.

      Toggle details void QLineEdit

      backspacebackspace () ()

      If no text is selected, 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.

      See also del().

      Look up this member in the source code.

      Toggle details void QLineEdit

      changeEventchangeEvent ( QEvent *ev ) ( QEvent *ev ) [virtual protected]

      Reimplemented from QWidget::changeEvent().

      Look up this member in the source code.

      Toggle details QCompleter * QLineEdit

      completercompleter () ()const

      Returns the current QCompleter that provides completions.

      See also setCompleter().

      Look up this member in the source code.

      Toggle details void QLineEdit

      contextMenuEventcontextMenuEvent ( QContextMenuEvent *event ) ( QContextMenuEvent *event ) [virtual protected]

      Reimplemented from QWidget::contextMenuEvent().

      Shows the standard context menu created with createStandardContextMenu().

      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 function. If you want to extend the standard context menu, reimplement this function, call createStandardContextMenu() and extend the menu returned.

      1. void LineEdit::contextMenuEvent(QContextMenuEvent *event)
      2.  {
      3.     QMenu *menu = createStandardContextMenu();
      4.     menu->addAction(tr("My Menu Item"));
      5.     //...
      6.     menu->exec(event->globalPos());
      7.     delete menu;
      8. }

      The event parameter is used to obtain the position where the mouse cursor was when the event was generated.

      See also setContextMenuPolicy().

      Look up this member in the source code.

      Toggle details QMenu * QLineEdit

      createStandardContextMenucreateStandardContextMenu () ()

      This function 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.

      Look up this member in the source code.

      Toggle details void QLineEdit

      cursorBackwardcursorBackward ( bool mark , int steps=1 ) ( 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.

      See also cursorForward().

      Look up this member in the source code.

      Toggle details void QLineEdit

      cursorForwardcursorForward ( bool mark , int steps=1 ) ( 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.

      See also cursorBackward().

      Look up this member in the source code.

      Toggle details int QLineEdit

      cursorPositionAtcursorPositionAt ( const QPoint &pos ) ( const QPoint &pos )

      Returns the cursor position under the point pos.

      Look up this member in the source code.

      Toggle details QRect QLineEdit

      cursorRectcursorRect () ()const[protected]

      Returns a rectangle that includes the lineedit cursor.

      Look up this member in the source code.

      Toggle details void QLineEdit

      cursorWordBackwardcursorWordBackward ( bool mark ) ( bool mark )

      Moves the cursor one word backward. If mark is true, the word is also selected.

      See also cursorWordForward().

      Look up this member in the source code.

      Toggle details void QLineEdit

      cursorWordForwardcursorWordForward ( bool mark ) ( bool mark )

      Moves the cursor one word forward. If mark is true, the word is also selected.

      See also cursorWordBackward().

      Look up this member in the source code.

      Toggle details void QLineEdit

      deldel () ()

      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.

      See also backspace().

      Look up this member in the source code.

      Toggle details void QLineEdit

      deselectdeselect () ()

      Deselects any selected text.

      See also setSelection() and selectAll().

      Look up this member in the source code.

      Toggle details void QLineEdit

      dragEnterEventdragEnterEvent ( QDragEnterEvent *e ) ( QDragEnterEvent *e ) [virtual protected]

      Reimplemented from QWidget::dragEnterEvent().

      Look up this member in the source code.

      Toggle details void QLineEdit

      dragLeaveEventdragLeaveEvent ( QDragLeaveEvent *e ) ( QDragLeaveEvent *e ) [virtual protected]

      Reimplemented from QWidget::dragLeaveEvent().

      Look up this member in the source code.

      Toggle details void QLineEdit

      dragMoveEventdragMoveEvent ( QDragMoveEvent *e ) ( QDragMoveEvent *e ) [virtual protected]

      Reimplemented from QWidget::dragMoveEvent().

      Look up this member in the source code.

      Toggle details void QLineEdit

      dropEventdropEvent ( QDropEvent *e ) ( QDropEvent *e ) [virtual protected]

      Reimplemented from QWidget::dropEvent().

      Look up this member in the source code.

      Toggle details void QLineEdit

      endend ( bool mark ) ( 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.

      See also home().

      Look up this member in the source code.

      Toggle details bool QLineEdit

      eventevent ( QEvent *e ) ( QEvent *e ) [virtual]

      Reimplemented from QObject::event().

      Look up this member in the source code.

      Toggle details void QLineEdit

      focusInEventfocusInEvent ( QFocusEvent *e ) ( QFocusEvent *e ) [virtual protected]

      Reimplemented from QWidget::focusInEvent().

      Look up this member in the source code.

      Toggle details void QLineEdit

      focusOutEventfocusOutEvent ( QFocusEvent *e ) ( QFocusEvent *e ) [virtual protected]

      Reimplemented from QWidget::focusOutEvent().

      Look up this member in the source code.

      Toggle details void QLineEdit

      getTextMarginsgetTextMargins ( int *left , int *top , int *right , int *bottom ...) ( int *left , int *top , int *right , int *bottom )const

      Returns the widget's text margins for left, top, right, and bottom.

      See also setTextMargins().

      Look up this member in the source code.

      Toggle details void QLineEdit

      homehome ( bool mark ) ( 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.

      See also end().

      Look up this member in the source code.

      Toggle details void QLineEdit

      initStyleOptioninitStyleOption ( QStyleOptionFrame *option ) ( QStyleOptionFrame *option )const[protected]

      Initialize option with the values from this QLineEdit. This method is useful for subclasses when they need a QStyleOptionFrame or QStyleOptionFrameV2, but don't want to fill in all the information themselves. This function will check the version of the QStyleOptionFrame and fill in the additional values for a QStyleOptionFrameV2.

      See also QStyleOption::initFrom().

      Look up this member in the source code.

      Toggle details void QLineEdit

      inputMethodEventinputMethodEvent ( QInputMethodEvent *e ) ( QInputMethodEvent *e ) [virtual protected]

      Reimplemented from QWidget::inputMethodEvent().

      Look up this member in the source code.

      Toggle details QVariant QLineEdit

      inputMethodQueryinputMethodQuery ( Qt::InputMethodQuery property ...) ( Qt::InputMethodQuery property )const [virtual]

      Reimplemented from QWidget::inputMethodQuery().

      Look up this member in the source code.

      Toggle details void QLineEdit

      insertinsert ( const QString &newText ) ( const QString &newText )

      Deletes any selected text, inserts newText, and validates the result. If it is valid, it sets it as the new contents of the line edit.

      See also setText() and clear().

      Look up this member in the source code.

      Toggle details void QLineEdit

      keyPressEventkeyPressEvent ( QKeyEvent *event ) ( QKeyEvent *event ) [virtual protected]

      Reimplemented from QWidget::keyPressEvent().

      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's detailed description.

      Look up this member in the source code.

      Toggle details QSize QLineEdit

      minimumSizeHintminimumSizeHint () ()const [virtual]

      Reimplemented from QWidget::minimumSizeHint().

      Returns a minimum size for the line edit.

      The width returned is enough for at least one character.

      Look up this member in the source code.

      Toggle details void QLineEdit

      mouseDoubleClickEventmouseDoubleClickEvent ( QMouseEvent *e ) ( QMouseEvent *e ) [virtual protected]

      Reimplemented from QWidget::mouseDoubleClickEvent().

      Look up this member in the source code.

      Toggle details void QLineEdit

      mouseMoveEventmouseMoveEvent ( QMouseEvent *e ) ( QMouseEvent *e ) [virtual protected]

      Reimplemented from QWidget::mouseMoveEvent().

      Look up this member in the source code.

      Toggle details void QLineEdit

      mousePressEventmousePressEvent ( QMouseEvent *e ) ( QMouseEvent *e ) [virtual protected]

      Reimplemented from QWidget::mousePressEvent().

      Look up this member in the source code.

      Toggle details void QLineEdit

      mouseReleaseEventmouseReleaseEvent ( QMouseEvent *e ) ( QMouseEvent *e ) [virtual protected]

      Reimplemented from QWidget::mouseReleaseEvent().

      Look up this member in the source code.

      Toggle details void QLineEdit

      paintEventpaintEvent ( QPaintEvent * ) ( QPaintEvent * ) [virtual protected]

      Reimplemented from QWidget::paintEvent().

      Look up this member in the source code.

      Toggle details int QLineEdit

      selectionStartselectionStart () ()const

      selectionStart() returns the index of the first selected character in the line edit or -1 if no text is selected.

      See also selectedText().

      Look up this member in the source code.

      Toggle details void QLineEdit

      setCompletersetCompleter ( QCompleter *c ) ( QCompleter *c )

      Sets this line edit to provide auto completions from the completer, c. The completion mode is set using QCompleter::setCompletionMode().

      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.

      If c == 0, setCompleter() removes the current completer, effectively disabling auto completion.

      See also completer() and QCompleter.

      Look up this member in the source code.

      Toggle details void QLineEdit

      setSelectionsetSelection ( int start , int length ) ( int start , int length )

      Selects text from position start and for length characters. Negative lengths are allowed.

      See also deselect(), selectAll(), and selectedText().

      Look up this member in the source code.

      Toggle details void QLineEdit

      setTextMarginssetTextMargins ( int left , int top , int right , int bottom ...) ( 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.

      See also getTextMargins().

      See also textMargins().

      Look up this member in the source code.

      Toggle details void QLineEdit

      setTextMarginssetTextMargins ( const QMargins &margins ) ( const QMargins &margins )

      Sets the margins around the text inside the frame.

      See also textMargins().

      Look up this member in the source code.

      Toggle details void QLineEdit

      setValidatorsetValidator ( const QValidator *v ) ( const QValidator *v )

      Sets this line edit to only accept input that the validator, v, will accept. This allows you to place any arbitrary constraints on the text which may be entered.

      If v == 0, setValidator() removes the current input validator. The initial setting is to have no input validator (i.e. any input is accepted up to maxLength()).

      See also validator(), QIntValidator, QDoubleValidator, and QRegExpValidator.

      Look up this member in the source code.

      Toggle details QSize QLineEdit

      sizeHintsizeHint () ()const [virtual]

      Reimplemented from QWidget::sizeHint().

      Returns a recommended size for the widget.

      The width returned, in pixels, is usually enough for about 15 to 20 characters.

      Look up this member in the source code.

      Toggle details QMargins QLineEdit

      textMarginstextMargins () ()const

      Returns the widget's text margins.

      See also setTextMargins().

      Look up this member in the source code.

      Toggle details const QValidator * QLineEdit

      validatorvalidator () ()const

      Returns a pointer to the current input validator, or 0 if no validator has been set.

      See also setValidator().

      Look up this member in the source code.

      Toggle details QLineEdit

      QLineEditQLineEdit ( QWidget *parent , const char *name ) ( QWidget *parent , const char *name ) Qt3-support

      Constructs a line edit with no text.

      The maximum text length is set to 32767 characters.

      The parent and name arguments are sent to the QWidget constructor.

      See also setText() and setMaxLength().

      Look up this member in the source code.

      Toggle details QLineEdit

      QLineEditQLineEdit ( const QString &contents , QWidget *parent , const char *name ...) ( const QString &contents , QWidget *parent , const char *name ) Qt3-support

      Constructs a line edit containing the text contents.

      The cursor position is set to the end of the line and the maximum text length to 32767 characters.

      The parent and name arguments are sent to the QWidget constructor.

      See also text() and setMaxLength().

      Look up this member in the source code.

      Toggle details QLineEdit

      QLineEditQLineEdit ( const QString &contents , const QString &inputMask , QWidget *parent=0 , const char *name=0 ...) ( const QString &contents , const QString &inputMask , QWidget *parent=0 , const char *name=0 ) Qt3-support

      Constructs a line edit with an input inputMask and the text contents.

      The cursor position is set to the end of the line and the maximum text length is set to the length of the mask (the number of mask characters and separators).

      The parent and name arguments are sent to the QWidget constructor.

      See also setMask() and text().

      Look up this member in the source code.

      Toggle details int QLineEdit

      characterAtcharacterAt ( int xpos , QChar *chr ) ( int xpos , QChar *chr )const Qt3-support

      There exists no equivalent functionality in Qt 4.

      Look up this member in the source code.

      Toggle details void QLineEdit

      clearModifiedclearModified () () Qt3-support

      Use setModified(false) instead.

      See also isModified().

      Look up this member in the source code.

      Toggle details void QLineEdit

      clearValidatorclearValidator () () Qt3-support

      Use setValidator(0) instead.

      Look up this member in the source code.

      Toggle details void QLineEdit

      cursorLeftcursorLeft ( bool mark , int steps=1 ) ( bool mark , int steps=1 ) Qt3-support

      Use cursorForward() with a negative number of steps instead. For example, cursorForward(mark, -steps).

      Look up this member in the source code.

      Toggle details void QLineEdit

      cursorRightcursorRight ( bool mark , int steps=1 ) ( bool mark , int steps=1 ) Qt3-support

      Use cursorForward() instead.

      Look up this member in the source code.

      Toggle details bool QLineEdit

      editededited () ()const Qt3-support

      Use isModified() instead.

      See also setEdited().

      Look up this member in the source code.

      Toggle details bool QLineEdit

      frameframe () ()const Qt3-support

      Use hasFrame() instead.

      See also setFrame().

      Look up this member in the source code.

      Toggle details bool QLineEdit

      getSelectiongetSelection ( int *start , int *end ) ( int *start , int *end ) Qt3-support

      Use selectedText() and selectionStart() instead.

      Look up this member in the source code.

      Toggle details bool QLineEdit

      hasMarkedTexthasMarkedText () ()const Qt3-support

      Use hasSelectedText() instead.

      Look up this member in the source code.

      Toggle details int QLineEdit

      marginmargin () ()const Qt3-support

      Returns the width of the margin around the contents of the widget.

      Use QWidget::getContentsMargins() instead.

      See also setMargin() and QWidget::getContentsMargins().

      Look up this member in the source code.

      Toggle details QString QLineEdit

      markedTextmarkedText () ()const Qt3-support

      Use selectedText() instead.

      Look up this member in the source code.

      Toggle details void QLineEdit

      repaintArearepaintArea ( int a , int b ) ( int a , int b )[protected] Qt3-support

      Use update() instead.

      Look up this member in the source code.

      Toggle details void QLineEdit

      setEditedsetEdited ( bool on ) ( bool on ) Qt3-support

      Use setModified() or setText().

      See also edited().

      Look up this member in the source code.

      Toggle details void QLineEdit

      setMarginsetMargin ( int margin ) ( int margin ) Qt3-support

      Sets the width of the margin around the contents of the widget to margin.

      Use QWidget::setContentsMargins() instead.

      See also margin() and QWidget::setContentsMargins().

      Look up this member in the source code.

      Toggle details bool QLineEdit

      validateAndSetvalidateAndSet ( const QString &newText , int newPos , int newMarkAnchor , int newMarkDrag ...) ( const QString &newText , int newPos , int newMarkAnchor , int newMarkDrag ) Qt3-support

      Use setText(), setCursorPosition() and setSelection() instead.

      Look up this member in the source code.

      Signals

      Toggle details void QLineEdit

      cursorPositionChangedcursorPositionChanged ( int old , int new ) ( int old , int new ) [signal]

      This signal is emitted whenever the cursor moves. The previous position is given by old, and the new position by new.

      See also setCursorPosition() and cursorPosition().

      Look up this member in the source code.

      Toggle details void QLineEdit

      editingFinishededitingFinished () () [signal]

      This signal is emitted when the Return or Enter key is pressed or the line edit loses focus. Note that 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 follows the inputMask() and the validator() returns QValidator::Acceptable.

      Look up this member in the source code.

      Toggle details void QLineEdit

      returnPressedreturnPressed () () [signal]

      This signal is emitted when the Return or Enter key is pressed. Note that if there is a validator() or inputMask() set on the line edit, the returnPressed() signal will only be emitted if the input follows the inputMask() and the validator() returns QValidator::Acceptable.

      Look up this member in the source code.

      Toggle details void QLineEdit

      selectionChangedselectionChanged () () [signal]

      This signal is emitted whenever the selection changes.

      See also hasSelectedText() and selectedText().

      Look up this member in the source code.

      Toggle details void QLineEdit

      textChangedtextChanged ( const QString &text ) ( const QString &text ) [signal]

      This signal is emitted whenever the text changes. The text argument is the new text.

      Unlike textEdited(), this signal is also emitted when the text is changed programmatically, for example, by calling setText().

      Look up this member in the source code.

      Toggle details void QLineEdit

      textEditedtextEdited ( const QString &text ) ( const QString &text ) [signal]

      This signal is emitted whenever the text is edited. The text argument is the next text.

      Unlike textChanged(), this signal is not emitted when the text is changed programmatically, for example, by calling setText().

      Look up this member in the source code.

      Toggle details void QLineEdit

      lostFocuslostFocus () () [signal] Qt3-support

      This signal is emitted when the line edit has lost focus.

      Use editingFinished() instead

      See also editingFinished() and returnPressed().

      Look up this member in the source code.

      Public Slots

      Toggle details void QLineEdit

      clearclear () () [slot]

      Clears the contents of the line edit.

      See also setText() and insert().

      Look up this member in the source code.

      Toggle details void QLineEdit

      copycopy () ()const [slot]

      Copies the selected text to the clipboard, if there is any, and if echoMode() is Normal.

      See also cut() and paste().

      Look up this member in the source code.

      Toggle details void QLineEdit

      cutcut () () [slot]

      Copies the selected text to the clipboard and deletes it, if there is any, and if echoMode() is Normal.

      If the current validator disallows deleting the selected text, cut() will copy without deleting.

      See also copy(), paste(), and setValidator().

      Look up this member in the source code.

      Toggle details void QLineEdit

      pastepaste () () [slot]

      Inserts the clipboard's text at the cursor position, deleting any selected text, providing the line edit is not read-only.

      If the end result would not be acceptable to the current validator, nothing happens.

      See also copy() and cut().

      Look up this member in the source code.

      Toggle details void QLineEdit

      redoredo () () [slot]

      Redoes the last operation if redo is available.

      Look up this member in the source code.

      Toggle details void QLineEdit

      selectAllselectAll () () [slot]

      Selects all the text (i.e. highlights it) and moves the cursor to the end. This is useful when a default value has been inserted because if the user types before clicking on the widget, the selected text will be deleted.

      See also setSelection() and deselect().

      Look up this member in the source code.

      Toggle details void QLineEdit

      undoundo () () [slot]

      Undoes the last operation if undo is available. Deselects any current selection, and updates the selection start to the current cursor position.

      Look up this member in the source code.

      Notes provided by the Qt Community

      No notes