CopperSpice API  1.7.2
QLineEdit Class Reference

Single line text edit widget. More...

Inheritance diagram for QLineEdit:
QWidget QObject QPaintDevice

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 &str)
 
void textEdited (const QString &str)
 
- 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 ()
 
QActionaddAction (const QIcon &icon, ActionPosition position)
 
void addAction (QAction *action)
 
void addAction (QAction *action, ActionPosition position)
 
Qt::Alignment alignment () const
 
void backspace ()
 
QCompletercompleter () const
 
QMenucreateStandardContextMenu ()
 
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) 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 QValidatorvalidator () 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
 
QBackingStorebackingStore () 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 QFontfont () const
 
QFontInfo fontInfo () const
 
QFontMetrics fontMetrics () const
 
QPalette::ColorRole foregroundRole () const
 
QRect frameGeometry () const
 
QSize frameSize () const
 
const QRectgeometry () 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)
 
QGraphicsEffectgraphicsEffect () const
 
QGraphicsProxyWidgetgraphicsProxyWidget () 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
 
QLayoutlayout () 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)
 
QPaintEnginepaintEngine () const override
 
const QPalettepalette () 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 &region)
 
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 &region)
 
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
 
QStylestyle () 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 &region)
 
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
 
QWindowwindowHandle () 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< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &objName=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 QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
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)
 
QThreadthread () 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 ()
 

Properties

 acceptableInput
 
 alignment
 
 clearButtonEnabled
 
 cursorMoveStyle
 
 cursorPosition
 
 displayText
 
 dragEnabled
 
 echoMode
 
 frame
 
 hasSelectedText
 
 inputMask
 
 maxLength
 
 modified
 
 placeholderText
 
 readOnly
 
 redoAvailable
 
 selectedText
 
 text
 
 undoAvailable
 
- Properties inherited from QWidget
 acceptDrops
 
 accessibleDescription
 
 accessibleName
 
 autoFillBackground
 
 baseSize
 
 childrenRect
 
 childrenRegion
 
 contextMenuPolicy
 
 cursor
 
 enabled
 
 focus
 
 focusPolicy
 
 font
 
 frameGeometry
 
 frameSize
 
 fullScreen
 
 geometry
 
 height
 
 inputMethodHints
 
 isActiveWindow
 
 layoutDirection
 
 locale
 
 maximized
 
 maximumHeight
 
 maximumSize
 
 maximumWidth
 
 minimized
 
 minimumHeight
 
 minimumSize
 
 minimumSizeHint
 
 minimumWidth
 
 modal
 
 mouseTracking
 
 normalGeometry
 
 palette
 
 pos
 
 rect
 
 size
 
 sizeHint
 
 sizeIncrement
 
 sizePolicy
 
 statusTip
 
 styleSheet
 
 toolTip
 
 updatesEnabled
 
 visible
 
 whatsThis
 
 width
 
 windowFilePath
 
 windowFlags
 
 windowIcon
 
 windowIconText
 
 windowModality
 
 windowModified
 
 windowOpacity
 
 windowTitle
 
 x
 
 y
 
- Properties inherited from QObject
 objectName
 

Friends

class QAbstractSpinBox
 
class QDateTimeEdit
 

Additional Inherited Members

- 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)
 
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 QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Slots inherited from QWidget
void updateMicroFocus ()
 

Detailed Description

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.

Notifications

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.

Shortcuts

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.

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.

Styles

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.
See also
QTextEdit, QLabel, QComboBox

Member Enumeration Documentation

This enum describes how a line edit should display the action widgets.

ConstantValueDescription
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.
See also
addAction(), removeAction(), QWidget::layoutDirection

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

ConstantValueDescription
QLineEdit::Normal0 Display characters as they are entered, this is the default.
QLineEdit::NoEcho1 Do not display anything. This may be appropriate for passwords where even the length of the password should be kept secret.
QLineEdit::Password2 Display asterisks instead of the characters actually entered.
QLineEdit::PasswordEchoOnEdit3 Display characters as they are entered while editing otherwise display asterisks.
See also
setEchoMode(), echoMode()

Constructor & Destructor Documentation

QLineEdit::QLineEdit ( QWidget parent = nullptr)
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.

See also
setText(), setMaxLength()
QLineEdit::QLineEdit ( const QString contents,
QWidget parent = nullptr 
)
explicit

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.

See also
text(), setMaxLength()
QLineEdit::~QLineEdit ( )

Destroys the line edit.

Method Documentation

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.

void QWidget::addAction ( QAction action)
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.

See also
removeAction(), insertAction(), actions(), QMenu
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.

See also
del()
void QLineEdit::changeEvent ( QEvent event)
overrideprotectedvirtual

This event handler can be reimplemented to handle state changes. The state being changed in this event can be retrieved through the event supplied.

Reimplemented from QWidget.

void QLineEdit::clear ( )
slot

Clears the contents of the line edit.

See also
setText(), insert()
QCompleter * QLineEdit::completer ( ) const

Returns the current QCompleter.

See also
setCompleter()
void QLineEdit::contextMenuEvent ( QContextMenuEvent event)
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.

void LineEdit::contextMenuEvent(QContextMenuEvent *event) {
menu->addAction(tr("My Menu Item"));
menu->exec(event->globalPos());
delete menu;
}
See also
setContextMenuPolicy()

Reimplemented from QWidget.

void QLineEdit::copy ( )
slot

Copies the selected text to the clipboard when the echoMode() is set to EchoMode::Normal.

See also
cut(), paste()
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.

See also
cursorForward()
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.

See also
cursorBackward()
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.

void QLineEdit::cursorPositionChanged ( int  oldValue,
int  newValue 
)
signal

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

See also
setCursorPosition(), cursorPosition()
QRect QLineEdit::cursorRect ( ) const
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.

See also
cursorWordForward()
void QLineEdit::cursorWordForward ( bool  mark)

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

See also
cursorWordBackward()
void QLineEdit::cut ( )
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.

See also
copy(), paste(), setValidator()
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.

See also
backspace()
void QLineEdit::deselect ( )

Deselects any selected text.

See also
setSelection(), selectAll()
QString QLineEdit::displayText ( ) const

Returns the value of the displayText property.

bool QLineEdit::dragEnabled ( ) const

Returns the value of the property.

void QLineEdit::dragEnterEvent ( QDragEnterEvent event)
overrideprotectedvirtual

This event handler is called when a drag is in progress and the mouse enters this widget. The event is passed in the event parameter. If the event is ignored, the widget will not receive any drag move events.

Refer to the Drag and Drop documentation for an overview of how to provide drag and drop in your application.

See also
QDrag, QDragEnterEvent

Reimplemented from QWidget.

void QLineEdit::dragLeaveEvent ( QDragLeaveEvent event)
overrideprotectedvirtual

This event handler is called when a drag is in progress and the mouse leaves this widget. The event is passed in the event parameter.

Refer to the Drag and Drop documentation for an overview of how to provide drag and drop in your application.

See also
QDrag, QDragLeaveEvent

Reimplemented from QWidget.

void QLineEdit::dragMoveEvent ( QDragMoveEvent event)
overrideprotectedvirtual

This event handler is called if a drag is in progress, and when any of the following conditions occur: the cursor enters this widget, the cursor moves within this widget, or a modifier key is pressed on the keyboard while this widget has the focus. The event is passed in the event parameter.

Refer to the Drag and Drop documentation for an overview of how to provide drag and drop in your application.

See also
QDrag, QDragMoveEvent

Reimplemented from QWidget.

void QLineEdit::dropEvent ( QDropEvent event)
overrideprotectedvirtual

This event handler is called when the drag is dropped on this widget. The event is passed in the event parameter.

Refer to the Drag and Drop documentation for an overview of how to provide drag and drop in your application.

See also
QDrag, QDropEvent

Reimplemented from QWidget.

EchoMode QLineEdit::echoMode ( ) const

Returns the value of the echoMode property.

void QLineEdit::editingFinished ( )
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.

See also
home()
bool QLineEdit::event ( QEvent event)
override

Refer to QWidget::event.

void QLineEdit::focusInEvent ( QFocusEvent event)
overrideprotectedvirtual

This event handler can be reimplemented in a subclass to receive keyboard focus events for the widget. The default implementation updates the widget if a focusPolicy() is specified. The event is passed in the event parameter.

A widget normally must the setFocusPolicy() to something other than Qt::NoFocus in order to receive focus events.

See also
focusOutEvent(), setFocusPolicy(), keyPressEvent(), keyReleaseEvent(), event(), QFocusEvent

Reimplemented from QWidget.

void QLineEdit::focusOutEvent ( QFocusEvent event)
overrideprotectedvirtual

This event handler can be reimplemented in a subclass to receive keyboard focus events for the widget. The default implementation updates the widget if a focusPolicy() is specified. The events is passed in the event parameter.

A widget normally must setFocusPolicy() to something other than Qt::NoFocus in order to receive focus events.

See also
focusInEvent(), setFocusPolicy(), keyPressEvent(), keyReleaseEvent(), event(), QFocusEvent

Reimplemented from QWidget.

void QLineEdit::getTextMargins ( int *  left,
int *  top,
int *  right,
int *  bottom 
) const

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

See also
setTextMargins()
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.

See also
end()
void QLineEdit::initStyleOption ( QStyleOptionFrame option) const
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.

See also
QStyleOption::initFrom()
QString QLineEdit::inputMask ( ) const

Returns the value for the inputMask property.

See also
setInputMask()
void QLineEdit::inputMethodEvent ( QInputMethodEvent event)
overrideprotectedvirtual

This event handler, for event event, can be reimplemented in a subclass to receive Input Method composition events. This handler is called when the state of the input method changes.

Note that when creating custom text editing widgets, the Qt::WA_InputMethodEnabled window attribute must be set explicitly (using the setAttribute() function) in order to receive input method events.

The default implementation calls event->ignore(), which rejects the Input Method event.

See also
event(), QInputMethodEvent

Reimplemented from QWidget.

QVariant QLineEdit::inputMethodQuery ( Qt::InputMethodQuery  query) const
overridevirtual

This method is only relevant for input widgets. It is used by the input method to query a set of properties of the widget to be able to support complex input method operations as support for surrounding text and reconversions.

The given query specifies which property is queried.

See also
inputMethodEvent(), QInputMethodEvent, inputMethodHints

Reimplemented from QWidget.

void QLineEdit::insert ( const QString newText)

Deletes any selected text, inserts newText and validates the result. If the result is invalid this method does nothing.

See also
setText(), clear()
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.

void QLineEdit::keyPressEvent ( QKeyEvent event)
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.

int QLineEdit::maxLength ( ) const

Returns the value of the maxLength property.

QSize QLineEdit::minimumSizeHint ( ) const
overridevirtual

Returns a minimum size for the line edit. The width returned is enough for at least one character.

Reimplemented from QWidget.

void QLineEdit::mouseDoubleClickEvent ( QMouseEvent event)
overrideprotectedvirtual

This event handler, for event event, can be reimplemented in a subclass to receive mouse double click events for the widget. The default implementation generates a normal mouse press event.

Note
The widget will also receive mouse press and mouse release events in addition to the double click event. It is up to the developer to ensure that the application interprets these events correctly.
See also
mousePressEvent(), mouseReleaseEvent(), mouseMoveEvent(), event(), QMouseEvent

Reimplemented from QWidget.

void QLineEdit::mouseMoveEvent ( QMouseEvent event)
overrideprotectedvirtual

This event handler, for event event, can be reimplemented in a subclass to receive mouse move events for the widget.

If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.

QMouseEvent::pos() reports the position of the mouse cursor, relative to this widget. For press and release events, the position is usually the same as the position of the last mouse move event, but it might be different if the user's hand shakes. This is a feature of the underlying window system, not CopperSpice.

If you want to show a tooltip immediately, while the mouse is moving (e.g., to get the mouse coordinates with QMouseEvent::pos() and show them as a tooltip), you must first enable mouse tracking as described above. Then, to ensure that the tooltip is updated immediately, you must call QToolTip::showText() instead of setToolTip() in your implementation of mouseMoveEvent().

See also
setMouseTracking(), mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), event(), QMouseEvent

Reimplemented from QWidget.

void QLineEdit::mousePressEvent ( QMouseEvent event)
overrideprotectedvirtual

This event handler, for event event, can be reimplemented in a subclass to receive mouse press events for the widget.

If you create new widgets in the mousePressEvent() the mouseReleaseEvent() may not end up where you expect, depending on the underlying window system (or X11 window manager), the widgets' location and maybe more.

The default implementation implements the closing of popup widgets when you click outside the window. For other widget types it does nothing.

See also
mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), event(), QMouseEvent

Reimplemented from QWidget.

void QLineEdit::mouseReleaseEvent ( QMouseEvent event)
overrideprotectedvirtual

This event handler, for event event, can be reimplemented in a subclass to receive mouse release events for the widget.

See also
mousePressEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), event(), QMouseEvent

Reimplemented from QWidget.

void QLineEdit::paintEvent ( QPaintEvent event)
overrideprotectedvirtual

This event handler can be reimplemented in a subclass to receive paint events passed in event. A paint event is a request to repaint all or part of a widget. It can happen for one of the following reasons.

  • repaint() or update() was invoked
  • widget was obscured and has now been uncovered
  • some other reason

Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QTableView do this, for example.

CopperSpice also tries to speed up painting by merging multiple paint events into one. When update() is called several times or the window system sends several paint events, CopperSpice merges these events into one event with a larger region (see QRegion::united()). The repaint() function does not permit this optimization, so we suggest using update() whenever possible.

When the paint event occurs, the update region has normally been erased, so you are painting on the widget's background. The background can be set using setBackgroundRole() and setPalette().

QWidget automatically double-buffers its painting, so there is no need to write double-buffering code in paintEvent() to avoid flicker.

For the X11 platform it is possible to toggle global double buffering by calling qt_x11_set_global_double_buffer().

extern void qt_x11_set_global_double_buffer(bool);
qt_x11_set_global_double_buffer(false);

Generally you should refrain from calling update() or repaint() inside a paintEvent(). For example, calling update() or repaint() on children inside a paintevent() results in undefined behavior; the child may or may not get a paint event.

Warning
If you are using a custom paint engine without the CopperSpice backingstore, Qt::WA_PaintOnScreen must be set. Otherwise, QWidget::paintEngine() will never be called; the backingstore will be used instead.
See also
event(), repaint(), update(), QPainter, QPixmap, QPaintEvent

Reimplemented from QWidget.

void QLineEdit::paste ( )
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 then this method does nothing.

See also
copy(), cut()
QString QLineEdit::placeholderText ( ) const

Returns the value of the placeholderText property.

void QLineEdit::redo ( )
slot

Redoes the last operation if redo is available.

void QLineEdit::returnPressed ( )
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.

void QLineEdit::selectAll ( )
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.

See also
setSelection(), deselect()
QString QLineEdit::selectedText ( ) const

Returns the value of the property.

void QLineEdit::selectionChanged ( )
signal

This signal is emitted when the selection changes.

See also
hasSelectedText(), selectedText()
int QLineEdit::selectionStart ( ) const

Returns the index of the first selected character in the line edit or -1 if no text is selected.

See also
selectedText()
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.

See also
completer(), QCompleter
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::setEchoMode ( EchoMode  )

Sets the value of the echoMode property.

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.

See also
QLineEdit::inputMask()
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.

See also
deselect(), selectAll(), selectedText()
void QLineEdit::setText ( const QString str)
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.

See also
textMargins()
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.

See also
textMargins(), getTextMargins()
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.

See also
validator(), QIntValidator, QDoubleValidator, QRegularExpressionValidator
QSize QLineEdit::sizeHint ( ) const
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.

QString QLineEdit::text ( ) const

Returns the value of the text property.

void QLineEdit::textChanged ( const QString str)
signal

This signal is emitted when the text changes. The str 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().

void QLineEdit::textEdited ( const QString str)
signal

This signal is emitted when the text is edited. The str argument is the new text.

QMargins QLineEdit::textMargins ( ) const

Returns the text margins for the line edit widget.

See also
setTextMargins()
void QLineEdit::undo ( )
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.

See also
setValidator()

Property Documentation

QLineEdit::acceptableInput

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

See also
setInputMask(), setValidator()
PropertiesClass Methods
read hasAcceptableInput
QLineEdit::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
PropertiesClass Methods
read alignment
write setAlignment
QLineEdit::clearButtonEnabled

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.

See also
addAction(), removeAction()
PropertiesClass Methods
read isClearButtonEnabled
write setClearButtonEnabled
QLineEdit::cursorMoveStyle

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.

PropertiesClass Methods
read cursorMoveStyle
write setCursorMoveStyle
QLineEdit::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.

PropertiesClass Methods
read cursorPosition
write setCursorPosition
QLineEdit::displayText

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.

See also
setEchoMode(), text(), EchoMode
PropertiesClass Methods
read displayText
QLineEdit::dragEnabled

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.

PropertiesClass Methods
read dragEnabled
write setDragEnabled
QLineEdit::echoMode

This property holds the 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.

See also
EchoMode, displayText()
PropertiesClass Methods
read echoMode
write setEchoMode
QLineEdit::frame

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.

PropertiesClass Methods
read hasFrame
write setFrame
QLineEdit::hasSelectedText

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.

See also
selectedText()
PropertiesClass Methods
read hasSelectedText
QLineEdit::inputMask

This property holds the validation input mask. Validators can be used instead of or in conjunction with masks. Refer to setValidator().

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.

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

At the end of the mask you can add a semicolon followed by any character. This character will be used to any place a "blank" or "space" should have been located. The special blank characters are always removed from the text after editing.

MaskNotes
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
See also
maxLength
PropertiesClass Methods
read inputMask
write setInputMask
QLineEdit::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
PropertiesClass Methods
read maxLength
write setMaxLength
QLineEdit::modified

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.

PropertiesClass Methods
read isModified
write setModified
designable true
QLineEdit::placeholderText

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.

See also
text()
PropertiesClass Methods
read placeholderText
write setPlaceholderText
QLineEdit::readOnly

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.

See also
setEnabled()
PropertiesClass Methods
read isReadOnly
write setReadOnly
QLineEdit::redoAvailable

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.

PropertiesClass Methods
read isRedoAvailable
QLineEdit::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()
PropertiesClass Methods
read selectedText
QLineEdit::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(), clear()
PropertiesClass Methods
read text
write setText
notify textChanged
user true
QLineEdit::undoAvailable

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.

PropertiesClass Methods
read isUndoAvailable