Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QLineEdit

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.core.QObject
                      com.trolltech.qt.gui.QWidget
                          com.trolltech.qt.gui.QLineEdit

All Implemented Interfaces:
  QPaintDeviceInterface, QtJambiInterface

    public class QLineEdit

extends QWidget

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.

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.

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.

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

| A line edit shown in the Macintosh widget style.
| A line edit shown in the Windows XP widget style.
| A line edit shown in the Plastique widget style.

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

Nested Class Summary
`static class` | `QLineEdit.EchoMode` This enum type describes how a line edit should display its contents.

Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
`QWidget.RenderFlag, QWidget.RenderFlags`

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary
`QSignalEmitter.Signal2` | `cursorPositionChanged` This signal takes 2 generic argument(s).
`QSignalEmitter.Signal0` | `editingFinished` This signal is emitted when the Return or Enter key is pressed or the line edit loses focus.
`QSignalEmitter.Signal0` | `returnPressed` This signal is emitted when the Return or Enter key is pressed.
`QSignalEmitter.Signal0` | `selectionChanged` This signal is emitted whenever the selection changes.
`QSignalEmitter.Signal1` | `textChanged` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `textEdited` This signal takes 1 generic argument(s).

Fields inherited from class com.trolltech.qt.gui.QWidget
`customContextMenuRequested`

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QLineEdit()` Constructs a line edit with no text.
`QLineEdit(QWidget parent)` Constructs a line edit with no text.
`QLineEdit(java.lang.String arg__1)` Constructs a line edit containing the text `contents`.
`QLineEdit(java.lang.String arg__1, QWidget parent)` Constructs a line edit containing the text `contents`.

Method Summary
`Qt.Alignment` | `alignment()` This property holds the alignment of the line edit.
`void` | `backspace()` If no text is selected, deletes the character to the left of the text cursor and moves the cursor one position to the left.
`void` | `clear()` Clears the contents of the line edit.
`QCompleter` | `completer()` Returns the current `QCompleter` that provides completions.
`void` | `copy()` Copies the selected text to the clipboard, if there is any, and if `echoMode()` is `Normal` .
`QMenu` | `createStandardContextMenu()` This function creates the standard context menu which is shown when the user clicks on the line edit with the right mouse button.
`void` | `cursorBackward(boolean mark)` Moves the cursor back `steps` characters.
`void` | `cursorBackward(boolean mark, int steps)` Moves the cursor back `steps` characters.
`void` | `cursorForward(boolean mark)` Moves the cursor forward `steps` characters.
`void` | `cursorForward(boolean mark, int steps)` Moves the cursor forward `steps` characters.
`int` | `cursorPosition()` This property holds the current cursor position for this line edit.
`int` | `cursorPositionAt(QPoint pos)` Returns the cursor position under the point `pos`.
`protected QRect` | `cursorRect()` Returns a rectangle that includes the lineedit cursor.
`void` | `cursorWordBackward(boolean mark)` Moves the cursor one word backward.
`void` | `cursorWordForward(boolean mark)` Moves the cursor one word forward.
`void` | `cut()` Copies the selected text to the clipboard and deletes it, if there is any, and if `echoMode()` is `Normal` .
`void` | `del()` If no text is selected, deletes the character to the right of the text cursor.
`void` | `deselect()` Deselects any selected text.
`java.lang.String` | `displayText()` This property holds the displayed text.
`boolean` | `dragEnabled()` This property holds whether the lineedit starts a drag if the user presses and moves the mouse on some selected text.
`QLineEdit.EchoMode` | `echoMode()` This property holds the line edit's echo mode.
`void` | `end(boolean mark)` Moves the text cursor to the end of the line unless it is already there.
`boolean` | `hasAcceptableInput()` This property holds whether the input satisfies the `inputMask` and the validator..
`boolean` | `hasFrame()` This property holds whether the line edit draws itself with a frame.
`boolean` | `hasSelectedText()` This property holds whether there is any text selected.
`void` | `home(boolean mark)` Moves the text cursor to the beginning of the line unless it is already there.
`protected void` | `initStyleOption(QStyleOptionFrame option)` This is a overloaded function provided for convenience.
`java.lang.String` | `inputMask()` This property holds The validation input mask.
`void` | `insert(java.lang.String arg__1)` Deletes any selected text, inserts `newText`, and validates the result.
`boolean` | `isModified()` This property holds whether the line edit's contents has been modified by the user.
`boolean` | `isReadOnly()` This property holds whether the line edit is read only.
`boolean` | `isRedoAvailable()` This property holds whether redo is available.
`boolean` | `isUndoAvailable()` This property holds whether undo is available.
`int` | `maxLength()` This property holds the maximum permitted length of the text.
`void` | `paste()` Inserts the clipboard's text at the cursor position, deleting any selected text, providing the line edit is not `read-only`.
`void` | `redo()` Redoes the last operation if redo is `available`.
`void` | `selectAll()` Selects all the text (i.
`java.lang.String` | `selectedText()` This property holds the selected text.
`int` | `selectionStart()` `selectionStart()` returns the index of the first selected character in the line edit or -1 if no text is selected.
`void` | `setAlignment(Qt.Alignment flag)` This property holds the alignment of the line edit.
`void` | `setAlignment(Qt.AlignmentFlag[] flag)`
`void` | `setCompleter(QCompleter completer)` Sets this line edit to provide auto completions from the completer, `c`.
`void` | `setCursorPosition(int arg__1)` This property holds the current cursor position for this line edit.
`void` | `setDragEnabled(boolean b)` This property holds whether the lineedit starts a drag if the user presses and moves the mouse on some selected text.
`void` | `setEchoMode(QLineEdit.EchoMode arg__1)` This property holds the line edit's echo mode.
`void` | `setFrame(boolean arg__1)` This property holds whether the line edit draws itself with a frame.
`void` | `setInputMask(java.lang.String inputMask)` This property holds The validation input mask.
`void` | `setMaxLength(int arg__1)` This property holds the maximum permitted length of the text.
`void` | `setModified(boolean arg__1)` This property holds whether the line edit's contents has been modified by the user.
`void` | `setReadOnly(boolean arg__1)` This property holds whether the line edit is read only.
`void` | `setSelection(int arg__1, int arg__2)` Selects text from position `start` and for `length` characters.
`void` | `setText(java.lang.String arg__1)` This property holds the line edit's text.
`void` | `setValidator(QValidator arg__1)` Sets this line edit to only accept input that the validator, `v`, will accept.
`java.lang.String` | `text()` This property holds the line edit's text.
`void` | `undo()` Undoes the last operation if undo is `available`.
`QValidator` | `validator()` Returns a pointer to the current input validator, or 0 if no validator has been set.

Methods inherited from class com.trolltech.qt.gui.QWidget
`acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, changeEvent, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuEvent, contextMenuPolicy, cursor, depth, destroy, destroy, destroy, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, effectiveWinId, ensurePolished, enterEvent, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isMaximized, isMinimized, isModal, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, languageChange, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, move, moveEvent, nativeParentWidget, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, paintEngine, paintEvent, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, resizeEvent, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFilePath, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeHint, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, widthMM, window, windowFilePath, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y`

Methods inherited from class com.trolltech.qt.core.QObject
`childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty`

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Field Detail

### cursorPositionChanged

    public final QSignalEmitter.Signal2 cursorPositionChanged

  This signal takes 2 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: old), java.lang.Integer(named: new)>:

  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()`.

### editingFinished

    public final QSignalEmitter.Signal0 editingFinished

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

### returnPressed

    public final QSignalEmitter.Signal0 returnPressed

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

### selectionChanged

    public final QSignalEmitter.Signal0 selectionChanged

  This signal is emitted whenever the selection changes.

See also:
  `hasSelectedText()`, and `selectedText()`.

### textChanged

    public final QSignalEmitter.Signal1 textChanged

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.String(named: text)>:

  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()`.

### textEdited

    public final QSignalEmitter.Signal1 textEdited

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.String(named: text)>:

  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()`.

Constructor Detail

### QLineEdit

    public QLineEdit()

  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()`.

### QLineEdit

    public QLineEdit(QWidget parent)

  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()`.

### QLineEdit

    public QLineEdit(java.lang.String arg__1)

  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()`.

### QLineEdit

    public QLineEdit(java.lang.String arg__1,
                     QWidget parent)

  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()`.

Method Detail

### alignment

    public final Qt.Alignment 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.

### backspace

    public final void backspace()

  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()`.

### clear

    public final void clear()

  Clears the contents of the line edit.

See also:
  `setText()`, and `insert()`.

### completer

    public final QCompleter completer()

  Returns the current `QCompleter` that provides completions.

See also:
  `setCompleter()`.

### copy

    public final void copy()

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

See also:
  `cut()`, and `paste()`.

### createStandardContextMenu

    public final QMenu createStandardContextMenu()

  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.

### cursorBackward

    public final void cursorBackward(boolean mark)

  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()`.

### cursorBackward

    public final void cursorBackward(boolean mark,
                                     int steps)

  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()`.

### cursorForward

    public final void cursorForward(boolean mark)

  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()`.

### cursorForward

    public final void cursorForward(boolean mark,
                                    int steps)

  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()`.

### cursorPosition

    public final int cursorPosition()

  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.

### cursorPositionAt

    public final int cursorPositionAt(QPoint pos)

  Returns the cursor position under the point `pos`.

### cursorRect

    protected final QRect cursorRect()

  Returns a rectangle that includes the lineedit cursor.

### cursorWordBackward

    public final void cursorWordBackward(boolean mark)

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

See also:
  `cursorWordForward()`.

### cursorWordForward

    public final void cursorWordForward(boolean mark)

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

See also:
  `cursorWordBackward()`.

### cut

    public final void cut()

  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()`.

### del

    public final void 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.

See also:
  `backspace()`.

### deselect

    public final void deselect()

  Deselects any selected text.

See also:
  `setSelection()`, and `selectAll()`.

### displayText

    public final java.lang.String displayText()

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

### dragEnabled

    public final boolean dragEnabled()

  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.

### echoMode

    public final QLineEdit.EchoMode 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()`.

### end

    public final void end(boolean 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()`.

### hasAcceptableInput

    public final boolean hasAcceptableInput()

  This property holds whether the input satisfies the `inputMask` and the validator.. By default, this property is true.

See also:
  `setInputMask()`, and `setValidator()`.

### hasFrame

    public final boolean hasFrame()

  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.

### hasSelectedText

    public final boolean hasSelectedText()

  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()`.

### home

    public final void home(boolean 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()`.

### inputMask

    public final java.lang.String inputMask()

  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.

  Character | Meaning
  --- | ---
  `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 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:

  Mask | Notes
  --- | ---
  `000.000.000.000;_` | IP address; blanks are `_`.
  `HH:HH:HH:HH:HH:HH;_` | MAC address
  `0000-00-00` | ISO 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`.

### insert

    public final void insert(java.lang.String arg__1)

  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()`.

### isModified

    public final boolean isModified()

  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.

### isReadOnly

    public final boolean isReadOnly()

  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().

### isRedoAvailable

    public final boolean isRedoAvailable()

  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.

### isUndoAvailable

    public final boolean isUndoAvailable()

  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.

### maxLength

    public final int maxLength()

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

### paste

    public final void paste()

  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()`.

### redo

    public final void redo()

  Redoes the last operation if redo is `available`.

### selectAll

    public final void selectAll()

  Selects all the text (i. . 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()`.

### selectedText

    public final java.lang.String selectedText()

  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()`.

### selectionStart

    public final int selectionStart()

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

See also:
  `selectedText()`.

### setAlignment

    public final void setAlignment(Qt.AlignmentFlag[] flag)

### setAlignment

    public final void setAlignment(Qt.Alignment flag)

  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.

### setCompleter

    public final void setCompleter(QCompleter completer)

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

### setCursorPosition

    public final void setCursorPosition(int arg__1)

  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.

### setDragEnabled

    public final void setDragEnabled(boolean b)

  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.

### setEchoMode

    public final void setEchoMode(QLineEdit.EchoMode arg__1)

  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()`.

### setFrame

    public final void setFrame(boolean arg__1)

  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.

### setInputMask

    public final void setInputMask(java.lang.String inputMask)

  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.

  Character | Meaning
  --- | ---
  `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 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:

  Mask | Notes
  --- | ---
  `000.000.000.000;_` | IP address; blanks are `_`.
  `HH:HH:HH:HH:HH:HH;_` | MAC address
  `0000-00-00` | ISO 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`.

### setMaxLength

    public final void setMaxLength(int arg__1)

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

### setModified

    public final void setModified(boolean arg__1)

  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.

### setReadOnly

    public final void setReadOnly(boolean arg__1)

  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().

### setSelection

    public final void setSelection(int arg__1,
                                   int arg__2)

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

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

### setText

    public final void setText(java.lang.String arg__1)

  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()`.

### setValidator

    public final void setValidator(QValidator arg__1)

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

### text

    public final java.lang.String text()

  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()`.

### undo

    public final void undo()

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

### validator

    public final QValidator validator()

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

See also:
  `setValidator()`.

### initStyleOption

    protected final void initStyleOption(QStyleOptionFrame option)

  This is a overloaded function provided for convenience.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD