QtBase  v6.3.1
Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties | Friends | List of all members
QLineEdit Class Reference

The QLineEdit widget is a one-line text editor. More...

#include <qlineedit.h>

Inheritance diagram for QLineEdit:
Inheritance graph
[legend]
Collaboration diagram for QLineEdit:
Collaboration graph
[legend]

Public Types

enum  ActionPosition { LeadingPosition , TrailingPosition }
 
enum  EchoMode { Normal , NoEcho , Password , PasswordEchoOnEdit }
 
- Public Types inherited from QWidget
enum  RenderFlag { DrawWindowBackground = 0x1 , DrawChildren = 0x2 , IgnoreMask = 0x4 }
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric {
  PdmWidth = 1 , PdmHeight , PdmWidthMM , PdmHeightMM ,
  PdmNumColors , PdmDepth , PdmDpiX , PdmDpiY ,
  PdmPhysicalDpiX , PdmPhysicalDpiY , PdmDevicePixelRatio , PdmDevicePixelRatioScaled
}
 

Public Slots

void setText (const QString &)
 
void clear ()
 
void selectAll ()
 
void undo ()
 
void redo ()
 
void cut ()
 
void copy () const
 
void paste ()
 
- Public Slots inherited from QWidget
void setEnabled (bool)
 
void setDisabled (bool)
 
void setWindowModified (bool)
 
void setWindowTitle (const QString &)
 
void setStyleSheet (const QString &styleSheet)
 
void setFocus ()
 
void update ()
 
void repaint ()
 
virtual void setVisible (bool visible)
 
void setHidden (bool hidden)
 
void show ()
 
void hide ()
 
void showMinimized ()
 
void showMaximized ()
 
void showFullScreen ()
 
void showNormal ()
 
bool close ()
 
void raise ()
 
void lower ()
 
- Public Slots inherited from QObject
void deleteLater ()
 

Signals

void textChanged (const QString &)
 
void textEdited (const QString &)
 
void cursorPositionChanged (int, int)
 
void returnPressed ()
 
void editingFinished ()
 
void selectionChanged ()
 
void inputRejected ()
 
- Signals inherited from QWidget
void windowTitleChanged (const QString &title)
 
void windowIconChanged (const QIcon &icon)
 
void windowIconTextChanged (const QString &iconText)
 
void customContextMenuRequested (const QPoint &pos)
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 

Public Member Functions

 QLineEdit (QWidget *parent=nullptr)
 
 QLineEdit (const QString &, QWidget *parent=nullptr)
 
 ~QLineEdit ()
 
QString text () const
 
QString displayText () const
 
QString placeholderText () const
 
void setPlaceholderText (const QString &)
 
int maxLength () const
 
void setMaxLength (int)
 
void setFrame (bool)
 
bool hasFrame () const
 
void setClearButtonEnabled (bool enable)
 
bool isClearButtonEnabled () const
 
EchoMode echoMode () const
 
void setEchoMode (EchoMode)
 
bool isReadOnly () const
 
void setReadOnly (bool)
 
void setValidator (const QValidator *)
 
const QValidatorvalidator () const
 
QSize sizeHint () const override
 
QSize minimumSizeHint () const override
 
int cursorPosition () const
 
void setCursorPosition (int)
 
int cursorPositionAt (const QPoint &pos)
 
void setAlignment (Qt::Alignment flag)
 
Qt::Alignment alignment () const
 
void cursorForward (bool mark, int steps=1)
 
void cursorBackward (bool mark, int steps=1)
 
void cursorWordForward (bool mark)
 
void cursorWordBackward (bool mark)
 
void backspace ()
 
void del ()
 
void home (bool mark)
 
void end (bool mark)
 
bool isModified () const
 
void setModified (bool)
 
void setSelection (int, int)
 
bool hasSelectedText () const
 
QString selectedText () const
 
int selectionStart () const
 
int selectionEnd () const
 
int selectionLength () const
 
bool isUndoAvailable () const
 
bool isRedoAvailable () const
 
void setDragEnabled (bool b)
 
bool dragEnabled () const
 
void setCursorMoveStyle (Qt::CursorMoveStyle style)
 
Qt::CursorMoveStyle cursorMoveStyle () const
 
QString inputMask () const
 
void setInputMask (const QString &inputMask)
 
bool hasAcceptableInput () const
 
void setTextMargins (int left, int top, int right, int bottom)
 
void setTextMargins (const QMargins &margins)
 
QMargins textMargins () const
 
void deselect ()
 
void insert (const QString &)
 
QMenucreateStandardContextMenu ()
 
QVariant inputMethodQuery (Qt::InputMethodQuery) const override
 
Q_INVOKABLE QVariant inputMethodQuery (Qt::InputMethodQuery property, QVariant argument) const
 
void timerEvent (QTimerEvent *) override
 
bool event (QEvent *) override
 
- Public Member Functions inherited from QWidget
 QWidget (QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
 
 ~QWidget ()
 
int devType () const override
 
WId winId () const
 
void createWinId ()
 
WId internalWinId () const
 
WId effectiveWinId () const
 
QStylestyle () const
 
void setStyle (QStyle *)
 
bool isWindow () const
 
bool isModal () const
 
Qt::WindowModality windowModality () const
 
void setWindowModality (Qt::WindowModality windowModality)
 
bool isEnabled () const
 
bool isEnabledTo (const QWidget *) const
 
QRect frameGeometry () const
 
const QRectgeometry () const
 
QRect normalGeometry () const
 
int x () const
 
int y () const
 
QPoint pos () const
 
QSize frameSize () const
 
QSize size () const
 
int width () const
 
int height () const
 
QRect rect () const
 
QRect childrenRect () const
 
QRegion childrenRegion () const
 
QSize minimumSize () const
 
QSize maximumSize () const
 
int minimumWidth () const
 
int minimumHeight () const
 
int maximumWidth () const
 
int maximumHeight () const
 
void setMinimumSize (const QSize &)
 
void setMinimumSize (int minw, int minh)
 
void setMaximumSize (const QSize &)
 
void setMaximumSize (int maxw, int maxh)
 
void setMinimumWidth (int minw)
 
void setMinimumHeight (int minh)
 
void setMaximumWidth (int maxw)
 
void setMaximumHeight (int maxh)
 
QSize sizeIncrement () const
 
void setSizeIncrement (const QSize &)
 
void setSizeIncrement (int w, int h)
 
QSize baseSize () const
 
void setBaseSize (const QSize &)
 
void setBaseSize (int basew, int baseh)
 
void setFixedSize (const QSize &)
 
void setFixedSize (int w, int h)
 
void setFixedWidth (int w)
 
void setFixedHeight (int h)
 
QPointF mapToGlobal (const QPointF &) const
 
QPoint mapToGlobal (const QPoint &) const
 
QPointF mapFromGlobal (const QPointF &) const
 
QPoint mapFromGlobal (const QPoint &) const
 
QPointF mapToParent (const QPointF &) const
 
QPoint mapToParent (const QPoint &) const
 
QPointF mapFromParent (const QPointF &) const
 
QPoint mapFromParent (const QPoint &) const
 
QPointF mapTo (const QWidget *, const QPointF &) const
 
QPoint mapTo (const QWidget *, const QPoint &) const
 
QPointF mapFrom (const QWidget *, const QPointF &) const
 
QPoint mapFrom (const QWidget *, const QPoint &) const
 
QWidgetwindow () const
 
QWidgetnativeParentWidget () const
 
QWidgettopLevelWidget () const
 
const QPalettepalette () const
 
void setPalette (const QPalette &)
 
void setBackgroundRole (QPalette::ColorRole)
 
QPalette::ColorRole backgroundRole () const
 
void setForegroundRole (QPalette::ColorRole)
 
QPalette::ColorRole foregroundRole () const
 
const QFontfont () const
 
void setFont (const QFont &)
 
QFontMetrics fontMetrics () const
 
QFontInfo fontInfo () const
 
QCursor cursor () const
 
void setCursor (const QCursor &)
 
void unsetCursor ()
 
void setMouseTracking (bool enable)
 
bool hasMouseTracking () const
 
bool underMouse () const
 
void setTabletTracking (bool enable)
 
bool hasTabletTracking () const
 
void setMask (const QBitmap &)
 
void setMask (const QRegion &)
 
QRegion mask () const
 
void clearMask ()
 
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))
 
Q_INVOKABLE QPixmap grab (const QRect &rectangle=QRect(QPoint(0, 0), QSize(-1, -1)))
 
void grabGesture (Qt::GestureType type, Qt::GestureFlags flags=Qt::GestureFlags())
 
void ungrabGesture (Qt::GestureType type)
 
QString styleSheet () const
 
QString windowTitle () const
 
void setWindowIcon (const QIcon &icon)
 
QIcon windowIcon () const
 
void setWindowIconText (const QString &)
 
QString windowIconText () const
 
void setWindowRole (const QString &)
 
QString windowRole () const
 
void setWindowFilePath (const QString &filePath)
 
QString windowFilePath () const
 
void setWindowOpacity (qreal level)
 
qreal windowOpacity () const
 
bool isWindowModified () const
 
QString accessibleName () const
 
void setAccessibleName (const QString &name)
 
QString accessibleDescription () const
 
void setAccessibleDescription (const QString &description)
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
Qt::LayoutDirection layoutDirection () const
 
void unsetLayoutDirection ()
 
void setLocale (const QLocale &locale)
 
QLocale locale () const
 
void unsetLocale ()
 
bool isRightToLeft () const
 
bool isLeftToRight () const
 
bool isActiveWindow () const
 
void activateWindow ()
 
void clearFocus ()
 
void setFocus (Qt::FocusReason reason)
 
Qt::FocusPolicy focusPolicy () const
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
bool hasFocus () const
 
void setFocusProxy (QWidget *)
 
QWidgetfocusProxy () const
 
Qt::ContextMenuPolicy contextMenuPolicy () const
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void grabMouse ()
 
void grabMouse (const QCursor &)
 
void releaseMouse ()
 
void grabKeyboard ()
 
void releaseKeyboard ()
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
 
void releaseShortcut (int id)
 
void setShortcutEnabled (int id, bool enable=true)
 
void setShortcutAutoRepeat (int id, bool enable=true)
 
bool updatesEnabled () const
 
void setUpdatesEnabled (bool enable)
 
void update (int x, int y, int w, int h)
 
void update (const QRect &)
 
void update (const QRegion &)
 
void repaint (int x, int y, int w, int h)
 
void repaint (const QRect &)
 
void repaint (const QRegion &)
 
void stackUnder (QWidget *)
 
void move (int x, int y)
 
void move (const QPoint &)
 
void resize (int w, int h)
 
void resize (const QSize &)
 
void setGeometry (int x, int y, int w, int h)
 
void setGeometry (const QRect &)
 
QByteArray saveGeometry () const
 
bool restoreGeometry (const QByteArray &geometry)
 
void adjustSize ()
 
bool isVisible () const
 
bool isVisibleTo (const QWidget *) const
 
bool isHidden () const
 
bool isMinimized () const
 
bool isMaximized () const
 
bool isFullScreen () const
 
Qt::WindowStates windowState () const
 
void setWindowState (Qt::WindowStates state)
 
void overrideWindowState (Qt::WindowStates state)
 
QSizePolicy sizePolicy () const
 
void setSizePolicy (QSizePolicy)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 
virtual int heightForWidth (int) const
 
virtual bool hasHeightForWidth () const
 
QRegion visibleRegion () const
 
void setContentsMargins (int left, int top, int right, int bottom)
 
void setContentsMargins (const QMargins &margins)
 The setContentsMargins function sets the margins around the widget's contents. More...
 
QMargins contentsMargins () const
 The contentsMargins function returns the widget's contents margins. More...
 
QRect contentsRect () const
 
QLayoutlayout () const
 
void setLayout (QLayout *)
 
void updateGeometry ()
 
void setParent (QWidget *parent)
 
void setParent (QWidget *parent, Qt::WindowFlags f)
 
void scroll (int dx, int dy)
 
void scroll (int dx, int dy, const QRect &)
 
QWidgetfocusWidget () const
 
QWidgetnextInFocusChain () const
 
QWidgetpreviousInFocusChain () const
 The previousInFocusChain function returns the previous widget in this widget's focus chain. More...
 
bool acceptDrops () const
 
void setAcceptDrops (bool on)
 
void addAction (QAction *action)
 
void addActions (const QList< QAction * > &actions)
 
void insertActions (QAction *before, const QList< QAction * > &actions)
 
void insertAction (QAction *before, QAction *action)
 
void removeAction (QAction *action)
 
QList< QAction * > actions () const
 
QActionaddAction (const QString &text)
 
QActionaddAction (const QIcon &icon, const QString &text)
 
QActionaddAction (const QString &text, const QObject *receiver, const char *member, Qt::ConnectionType type=Qt::AutoConnection)
 
QActionaddAction (const QIcon &icon, const QString &text, const QObject *receiver, const char *member, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename... Args, typename = compatible_action_slot_args<Args...>>
QActionaddAction (const QString &text, Args &&...args)
 
template<typename... Args, typename = compatible_action_slot_args<Args...>>
QActionaddAction (const QIcon &icon, const QString &text, Args &&...args)
 
QWidgetparentWidget () const
 
void setWindowFlags (Qt::WindowFlags type)
 
Qt::WindowFlags windowFlags () const
 
void setWindowFlag (Qt::WindowType, bool on=true)
 
void overrideWindowFlags (Qt::WindowFlags type)
 
Qt::WindowType windowType () const
 
QWidgetchildAt (int x, int y) const
 
QWidgetchildAt (const QPoint &p) const
 
void setAttribute (Qt::WidgetAttribute, bool on=true)
 
bool testAttribute (Qt::WidgetAttribute) const
 
QPaintEnginepaintEngine () const override
 
void ensurePolished () const
 
bool isAncestorOf (const QWidget *child) const
 
bool autoFillBackground () const
 
void setAutoFillBackground (bool enabled)
 
QBackingStorebackingStore () const
 
QWindowwindowHandle () const
 
QScreenscreen () const
 
void setScreen (QScreen *)
 
Qt::InputMethodHints inputMethodHints () const
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 
virtual ~QObject ()
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const
 
void setObjectName (const QString &name)
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const noexcept
 
bool blockSignals (bool b) noexcept
 
QThreadthread () const
 
void moveToThread (QThread *thread)
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 
template<typename T >
T findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
const QObjectListchildren () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 
void dumpObjectInfo () const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 
bool inherits (const char *classname) const
 
- Public Member Functions inherited from QPaintDevice
virtual ~QPaintDevice ()
 
bool paintingActive () const
 
int width () const
 
int height () const
 
int widthMM () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
qreal devicePixelRatio () const
 
qreal devicePixelRatioF () const
 
int colorCount () const
 
int depth () const
 

Protected Member Functions

void mousePressEvent (QMouseEvent *) override
 
void mouseMoveEvent (QMouseEvent *) override
 
void mouseReleaseEvent (QMouseEvent *) override
 
void mouseDoubleClickEvent (QMouseEvent *) override
 
void keyPressEvent (QKeyEvent *) override
 
void keyReleaseEvent (QKeyEvent *) override
 
void focusInEvent (QFocusEvent *) override
 
void focusOutEvent (QFocusEvent *) override
 
void paintEvent (QPaintEvent *) override
 
void changeEvent (QEvent *) override
 
void contextMenuEvent (QContextMenuEvent *) override
 
void inputMethodEvent (QInputMethodEvent *) override
 
virtual void initStyleOption (QStyleOptionFrame *option) const
 
QRect cursorRect () const
 
- Protected Member Functions inherited from QWidget
virtual void enterEvent (QEnterEvent *event)
 
virtual void leaveEvent (QEvent *event)
 
virtual void moveEvent (QMoveEvent *event)
 
virtual void resizeEvent (QResizeEvent *event)
 
virtual void closeEvent (QCloseEvent *event)
 
virtual void actionEvent (QActionEvent *event)
 
virtual void showEvent (QShowEvent *event)
 
virtual void hideEvent (QHideEvent *event)
 
virtual bool nativeEvent (const QByteArray &eventType, void *message, qintptr *result)
 
int metric (PaintDeviceMetric) const override
 
void initPainter (QPainter *painter) const override
 
QPaintDeviceredirected (QPoint *offset) const override
 
QPaintersharedPainter () const override
 
void create (WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
 
void destroy (bool destroyWindow=true, bool destroySubWindows=true)
 
virtual bool focusNextPrevChild (bool next)
 
bool focusNextChild ()
 
bool focusPreviousChild ()
 
 QWidget (QWidgetPrivate &d, QWidget *parent, Qt::WindowFlags f)
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 
- Protected Member Functions inherited from QPaintDevice
 QPaintDevice () noexcept
 

Properties

QString inputMask
 The validation input mask. More...
 
QString text
 the line edit's text. More...
 
int maxLength
 the maximum permitted length of the text. More...
 
bool frame
 whether the line edit draws itself with a frame. More...
 
EchoMode echoMode
 the line edit's echo mode. More...
 
QString displayText
 the displayed text. More...
 
int cursorPosition
 the current cursor position for this line edit. More...
 
Qt::Alignment alignment
 the alignment of the line edit. More...
 
bool modified
 whether the line edit's contents has been modified by the user. More...
 
bool hasSelectedText
 whether there is any text selected. More...
 
QString selectedText
 the selected text. More...
 
bool dragEnabled
 whether the lineedit starts a drag if the user presses and moves the mouse on some selected text. More...
 
bool readOnly
 whether the line edit is read only. More...
 
bool undoAvailable
 whether undo is available. More...
 
bool redoAvailable
 whether redo is available. More...
 
bool acceptableInput
 whether the input satisfies the inputMask and the validator. More...
 
QString placeholderText
 the line edit's placeholder text. More...
 
Qt::CursorMoveStyle cursorMoveStyle
 the movement style of cursor in this line edit. More...
 
bool clearButtonEnabled
 Whether the line edit displays a clear button when it is not empty. More...
 
- Properties inherited from QWidget
bool modal
 whether the widget is a modal widget More...
 
Qt::WindowModality windowModality
 which windows are blocked by the modal widget More...
 
bool enabled
 whether the widget is enabled More...
 
QRect geometry
 the geometry of the widget relative to its parent and excluding the window frame More...
 
QRect frameGeometry
 geometry of the widget relative to its parent including any window frame More...
 
QRect normalGeometry
 the geometry of the widget as it will appear when shown as a normal (not maximized or full screen) top-level widget More...
 
int x
 the x coordinate of the widget relative to its parent including any window frame More...
 
int y
 the y coordinate of the widget relative to its parent and including any window frame More...
 
QPoint pos
 the position of the widget within its parent widget More...
 
QSize frameSize
 the size of the widget including any window frame More...
 
QSize size
 the size of the widget excluding any window frame More...
 
int width
 the width of the widget excluding any window frame More...
 
int height
 the height of the widget excluding any window frame More...
 
QRect rect
 the internal geometry of the widget excluding any window frame More...
 
QRect childrenRect
 the bounding rectangle of the widget's children More...
 
QRegion childrenRegion
 the combined region occupied by the widget's children More...
 
QSizePolicy sizePolicy
 the default layout behavior of the widget More...
 
QSize minimumSize
 the widget's minimum size More...
 
QSize maximumSize
 the widget's maximum size in pixels More...
 
int minimumWidth
 the widget's minimum width in pixels More...
 
int minimumHeight
 the widget's minimum height in pixels More...
 
int maximumWidth
 the widget's maximum width in pixels More...
 
int maximumHeight
 the widget's maximum height in pixels More...
 
QSize sizeIncrement
 the size increment of the widget More...
 
QSize baseSize
 the base size of the widget More...
 
QPalette palette
 the widget's palette More...
 
QFont font
 the font currently set for the widget More...
 
QCursor cursor
 the cursor shape for this widget More...
 
bool mouseTracking
 whether mouse tracking is enabled for the widget More...
 
bool tabletTracking
 whether tablet tracking is enabled for the widget More...
 
bool isActiveWindow
 whether this widget's window is the active window More...
 
Qt::FocusPolicy focusPolicy
 the way the widget accepts keyboard focus More...
 
bool focus
 whether this widget (or its focus proxy) has the keyboard input focus More...
 
Qt::ContextMenuPolicy contextMenuPolicy
 how the widget shows a context menu More...
 
bool updatesEnabled
 whether updates are enabled More...
 
bool visible
 whether the widget is visible More...
 
bool minimized
 whether this widget is minimized (iconified) More...
 
bool maximized
 whether this widget is maximized More...
 
bool fullScreen
 whether the widget is shown in full screen mode More...
 
QSize sizeHint
 the recommended size for the widget More...
 
QSize minimumSizeHint
 the recommended minimum size for the widget More...
 
bool acceptDrops
 whether drop events are enabled for this widget More...
 
QString windowTitle
 the window title (caption) More...
 
QIcon windowIcon
 the widget's icon More...
 
QString windowIconText
 the text to be displayed on the icon of a minimized window More...
 
double windowOpacity
 The level of opacity for the window. More...
 
bool windowModified
 whether the document shown in the window has unsaved changes More...
 
QString accessibleName
 the widget's name as seen by assistive technologies More...
 
QString accessibleDescription
 the widget's description as seen by assistive technologies More...
 
Qt::LayoutDirection layoutDirection
 the layout direction for this widget. More...
 
bool autoFillBackground
 whether the widget background is filled automatically More...
 
QString styleSheet
 the widget's style sheet More...
 
QLocale locale
 the widget's locale More...
 
QString windowFilePath
 the file path associated with a widget More...
 
Qt::InputMethodHints inputMethodHints
 What input method specific hints the widget has. More...
 
- Properties inherited from QObject
QString objectName
 the name of this object More...
 

Friends

class QAbstractSpinBox
 
class QAccessibleLineEdit
 
class QComboBox
 

Additional Inherited Members

- Static Public Member Functions inherited from QWidget
static void setTabOrder (QWidget *, QWidget *)
 
static QWidgetmouseGrabber ()
 
static QWidgetkeyboardGrabber ()
 
static QWidgetfind (WId)
 
static QWidgetcreateWindowContainer (QWindow *window, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Static Public Member Functions inherited from QPaintDevice
static qreal devicePixelRatioFScale ()
 
- Protected Slots inherited from QWidget
void updateMicroFocus (Qt::InputMethodQuery query=Qt::ImQueryAll)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Attributes inherited from QPaintDevice
ushort painters
 

Detailed Description

The QLineEdit widget is a one-line text editor.

\inmodule QtWidgets

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 (see \l setDragEnabled()).

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

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

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

You can change the text with setText() or insert(). The text is retrieved with text(); the displayed text (which may be different, see \l{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 focus is lost without any changes done, the editingFinished() signal won't be 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 platform 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. \target desc \table \header

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

See also
QTextEdit, QLabel, QComboBox, {Line Edits Example}

Definition at line 63 of file qlineedit.h.

Member Enumeration Documentation

◆ ActionPosition

This enum type describes how a line edit should display the action widgets to be added.

\value LeadingPosition The widget is displayed to the left of the text when using layout direction Qt::LeftToRight or to the right when using Qt::RightToLeft, respectively.

\value TrailingPosition The 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
Since
5.2
Enumerator
LeadingPosition 
TrailingPosition 

Definition at line 87 of file qlineedit.h.

◆ EchoMode

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

\value Normal Display characters as they are entered. This is the default. \value NoEcho Do not display anything. This may be appropriate for passwords where even the length of the password should be kept secret. \value Password Display platform-dependent password mask characters instead of the characters actually entered. \value PasswordEchoOnEdit Display characters as they are entered while editing otherwise display characters as with Password.

See also
setEchoMode(), echoMode()
Enumerator
Normal 
NoEcho 
Password 
PasswordEchoOnEdit 

Definition at line 113 of file qlineedit.h.

Constructor & Destructor Documentation

◆ QLineEdit() [1/2]

QLineEdit::QLineEdit ( QWidget parent = nullptr)
explicit

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(), setMaxLength()

Definition at line 261 of file qlineedit.cpp.

◆ QLineEdit() [2/2]

QLineEdit::QLineEdit ( const QString contents,
QWidget parent = nullptr 
)
explicit

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(), setMaxLength()

Definition at line 277 of file qlineedit.cpp.

◆ ~QLineEdit()

QLineEdit::~QLineEdit ( )

Destroys the line edit.

Definition at line 290 of file qlineedit.cpp.

Member Function Documentation

◆ alignment()

Qt::Alignment QLineEdit::alignment ( ) const

Definition at line 778 of file qlineedit.cpp.

◆ backspace()

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

Definition at line 853 of file qlineedit.cpp.

◆ changeEvent()

void QLineEdit::changeEvent ( QEvent ev)
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 2284 of file qlineedit.cpp.

Here is the call graph for this function:

◆ clear

void QLineEdit::clear ( )
slot

Clears the contents of the line edit.

See also
setText(), insert()

Definition at line 1313 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ contextMenuEvent()

void QLineEdit::contextMenuEvent ( QContextMenuEvent event)
overrideprotectedvirtual

Shows the standard context menu created with createStandardContextMenu().

If you do not want the line edit to have a context menu, you can set its \l contextMenuPolicy to Qt::NoContextMenu. If you want to customize the context menu, reimplement this function. If you want to extend the standard context menu, reimplement this function, call createStandardContextMenu() and extend the menu returned.

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

See also
setContextMenuPolicy()

Reimplemented from QWidget.

Definition at line 2193 of file qlineedit.cpp.

Here is the call graph for this function:

◆ copy

void QLineEdit::copy ( ) const
slot

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

See also
cut(), paste()

Definition at line 1415 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ createStandardContextMenu()

QMenu * QLineEdit::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.

Definition at line 2214 of file qlineedit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cursorBackward()

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

Definition at line 814 of file qlineedit.cpp.

Here is the call graph for this function:

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

Definition at line 800 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ cursorMoveStyle()

Qt::CursorMoveStyle QLineEdit::cursorMoveStyle ( ) const

Definition at line 1107 of file qlineedit.cpp.

◆ cursorPosition()

int QLineEdit::cursorPosition ( ) const

Definition at line 742 of file qlineedit.cpp.

◆ cursorPositionAt()

int QLineEdit::cursorPositionAt ( const QPoint pos)

Returns the cursor position under the point pos.

Definition at line 758 of file qlineedit.cpp.

Here is the call graph for this function:

◆ cursorPositionChanged

void QLineEdit::cursorPositionChanged ( int  oldPos,
int  newPos 
)
signal

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

See also
setCursorPosition(), cursorPosition()

◆ cursorRect()

QRect QLineEdit::cursorRect ( ) const
protected
Since
4.4

Returns a rectangle that includes the lineedit cursor.

Definition at line 1797 of file qlineedit.cpp.

◆ cursorWordBackward()

void QLineEdit::cursorWordBackward ( bool  mark)

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

See also
cursorWordForward()

Definition at line 838 of file qlineedit.cpp.

◆ cursorWordForward()

void QLineEdit::cursorWordForward ( bool  mark)

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

See also
cursorWordBackward()

Definition at line 825 of file qlineedit.cpp.

◆ cut

void QLineEdit::cut ( )
slot

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

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

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

Definition at line 1399 of file qlineedit.cpp.

Here is the call graph for this function:

◆ del()

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

Definition at line 867 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ deselect()

void QLineEdit::deselect ( )

Deselects any selected text.

See also
setSelection(), selectAll()

Definition at line 1287 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ displayText()

QString QLineEdit::displayText ( ) const

Definition at line 370 of file qlineedit.cpp.

◆ dragEnabled()

bool QLineEdit::dragEnabled ( ) const

Definition at line 1079 of file qlineedit.cpp.

◆ echoMode()

QLineEdit::EchoMode QLineEdit::echoMode ( ) const

Definition at line 566 of file qlineedit.cpp.

◆ editingFinished

void QLineEdit::editingFinished ( )
signal

This signal is emitted when the Return or Enter key is pressed, or if the line edit loses focus and its contents have changed since the last time this signal was emitted.

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.

Here is the caller graph for this function:

◆ end()

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

Definition at line 897 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ event()

bool QLineEdit::event ( QEvent e)
overridevirtual

\reimp

Reimplemented from QWidget.

Definition at line 1458 of file qlineedit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ focusInEvent()

void QLineEdit::focusInEvent ( QFocusEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Reimplemented in LineEdit, LineEdit, and FocusLineEdit.

Definition at line 1895 of file qlineedit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ focusOutEvent()

void QLineEdit::focusOutEvent ( QFocusEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Reimplemented in LineEdit, LineEdit, and FocusLineEdit.

Definition at line 1938 of file qlineedit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasAcceptableInput()

bool QLineEdit::hasAcceptableInput ( ) const

Definition at line 1128 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ hasFrame()

bool QLineEdit::hasFrame ( ) const

Definition at line 414 of file qlineedit.cpp.

◆ hasSelectedText()

bool QLineEdit::hasSelectedText ( ) const

Definition at line 947 of file qlineedit.cpp.

◆ home()

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

Definition at line 882 of file qlineedit.cpp.

◆ initStyleOption()

QT_BEGIN_NAMESPACE void QLineEdit::initStyleOption ( QStyleOptionFrame option) const
protectedvirtual

Initialize option with the values from this QLineEdit. This method is useful for subclasses when they need a QStyleOptionFrame, but don't want to fill in all the information themselves.

See also
QStyleOption::initFrom()

Definition at line 107 of file qlineedit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inputMask()

QString QLineEdit::inputMask ( ) const

Definition at line 1254 of file qlineedit.cpp.

◆ inputMethodEvent()

void QLineEdit::inputMethodEvent ( QInputMethodEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 1805 of file qlineedit.cpp.

Here is the call graph for this function:

◆ inputMethodQuery() [1/2]

QVariant QLineEdit::inputMethodQuery ( Qt::InputMethodQuery  property,
QVariant  argument 
) const

Definition at line 1844 of file qlineedit.cpp.

Here is the call graph for this function:

◆ inputMethodQuery() [2/2]

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

\reimp

Reimplemented from QWidget.

Definition at line 1837 of file qlineedit.cpp.

Here is the call graph for this function:

◆ inputRejected

void QLineEdit::inputRejected ( )
signal
Since
5.12

This signal is emitted when the user presses a key that is not considered to be acceptable input. For example, if a key press results in a validator's validate() call to return Invalid. Another case is when trying to enter in more characters beyond the maximum length of the line edit.

Note: This signal will still be emitted in a case where part of the text is accepted but not all of it is. For example, if there is a maximum length set and the clipboard text is longer than the maximum length when it is pasted.

◆ insert()

void QLineEdit::insert ( const QString newText)

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

See also
setText(), clear()

Definition at line 1301 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ isClearButtonEnabled()

bool QLineEdit::isClearButtonEnabled ( ) const

Definition at line 507 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ isModified()

bool QLineEdit::isModified ( ) const

Definition at line 922 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ isReadOnly()

bool QLineEdit::isReadOnly ( ) const

Definition at line 1358 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ isRedoAvailable()

bool QLineEdit::isRedoAvailable ( ) const

Definition at line 1065 of file qlineedit.cpp.

◆ isUndoAvailable()

bool QLineEdit::isUndoAvailable ( ) const

Definition at line 1049 of file qlineedit.cpp.

◆ keyPressEvent()

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 \l{QValidator::fixup()}{made valid} by the validator), the signal returnPressed() is emitted.

The default key bindings are listed in the class's detailed description.

Reimplemented from QWidget.

Reimplemented in LineEdit, and FocusLineEdit.

Definition at line 1731 of file qlineedit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ keyReleaseEvent()

void QLineEdit::keyReleaseEvent ( QKeyEvent )
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 1784 of file qlineedit.cpp.

Here is the call graph for this function:

◆ maxLength()

int QLineEdit::maxLength ( ) const

Definition at line 395 of file qlineedit.cpp.

◆ minimumSizeHint()

QSize QLineEdit::minimumSizeHint ( ) const
overridevirtual

Returns a minimum size for the line edit.

The width returned is usually enough for at least one character.

Reimplemented from QWidget.

Definition at line 715 of file qlineedit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouseDoubleClickEvent()

void QLineEdit::mouseDoubleClickEvent ( QMouseEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 1636 of file qlineedit.cpp.

Here is the call graph for this function:

◆ mouseMoveEvent()

void QLineEdit::mouseMoveEvent ( QMouseEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 1557 of file qlineedit.cpp.

Here is the call graph for this function:

◆ mousePressEvent()

void QLineEdit::mousePressEvent ( QMouseEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 1515 of file qlineedit.cpp.

Here is the call graph for this function:

◆ mouseReleaseEvent()

void QLineEdit::mouseReleaseEvent ( QMouseEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 1604 of file qlineedit.cpp.

Here is the call graph for this function:

◆ paintEvent()

void QLineEdit::paintEvent ( QPaintEvent )
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Reimplemented in UpdateRegionLineEdit, and BlinkTestLineEdit.

Definition at line 1978 of file qlineedit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ paste

void QLineEdit::paste ( )
slot

Inserts the clipboard's text at the cursor position, deleting any selected text, providing the line edit is not \l{QLineEdit::readOnly}{read-only}.

If the end result would be invalid to the current \l{setValidator()}{validator}, nothing happens.

See also
copy(), cut()

Definition at line 1431 of file qlineedit.cpp.

◆ placeholderText()

QString QLineEdit::placeholderText ( ) const

Definition at line 340 of file qlineedit.cpp.

◆ redo

void QLineEdit::redo ( )
slot

Redoes the last operation if redo is \l{QLineEdit::redoAvailable}{available}.

Definition at line 1335 of file qlineedit.cpp.

◆ returnPressed

void QLineEdit::returnPressed ( )
signal

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

Here is the caller graph for this function:

◆ selectAll

void QLineEdit::selectAll ( )
slot

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

See also
setSelection(), deselect()

Definition at line 1275 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ selectedText()

QString QLineEdit::selectedText ( ) const

Definition at line 965 of file qlineedit.cpp.

◆ selectionChanged

void QLineEdit::selectionChanged ( )
signal

This signal is emitted whenever the selection changes.

See also
hasSelectedText(), selectedText()

◆ selectionEnd()

int QLineEdit::selectionEnd ( ) const

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

Since
5.10
See also
selectedText()
selectionStart()
selectionLength()

Definition at line 995 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ selectionLength()

int QLineEdit::selectionLength ( ) const

Returns the length of the selection.

Since
5.10
See also
selectedText()
selectionStart()
selectionEnd()

Definition at line 1009 of file qlineedit.cpp.

Here is the call graph for this function:

◆ selectionStart()

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()
selectionEnd()
selectionLength()

Definition at line 980 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ setAlignment()

void QLineEdit::setAlignment ( Qt::Alignment  flag)

Definition at line 784 of file qlineedit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setClearButtonEnabled()

void QLineEdit::setClearButtonEnabled ( bool  enable)

Definition at line 482 of file qlineedit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setCursorMoveStyle()

void QLineEdit::setCursorMoveStyle ( Qt::CursorMoveStyle  style)

Definition at line 1113 of file qlineedit.cpp.

Here is the call graph for this function:

◆ setCursorPosition()

void QLineEdit::setCursorPosition ( int  pos)

Definition at line 748 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ setDragEnabled()

void QLineEdit::setDragEnabled ( bool  b)

Definition at line 1085 of file qlineedit.cpp.

◆ setEchoMode()

void QLineEdit::setEchoMode ( EchoMode  mode)

Definition at line 572 of file qlineedit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFrame()

void QLineEdit::setFrame ( bool  enable)

Definition at line 516 of file qlineedit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setInputMask()

void QLineEdit::setInputMask ( const QString inputMask)

Definition at line 1260 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ setMaxLength()

void QLineEdit::setMaxLength ( int  maxLength)

Definition at line 401 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ setModified()

void QLineEdit::setModified ( bool  modified)

Definition at line 928 of file qlineedit.cpp.

◆ setPlaceholderText()

void QLineEdit::setPlaceholderText ( const QString placeholderText)

Definition at line 346 of file qlineedit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setReadOnly()

void QLineEdit::setReadOnly ( bool  enable)

Definition at line 1364 of file qlineedit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSelection()

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

Definition at line 1021 of file qlineedit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setText

void QLineEdit::setText ( const QString text)
slot

Definition at line 316 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ setTextMargins() [1/2]

void QLineEdit::setTextMargins ( const QMargins margins)
Since
4.6 Sets the margins around the text inside the frame.

See also textMargins().

Definition at line 1152 of file qlineedit.cpp.

Here is the call graph for this function:

◆ setTextMargins() [2/2]

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.

Since
4.5

See also textMargins().

Definition at line 1141 of file qlineedit.cpp.

◆ setValidator()

void QLineEdit::setValidator ( const QValidator v)

Sets the validator for values of line edit to v.

The line edit's returnPressed() and editingFinished() signals will only be emitted if v validates the line edit's content as \l{QValidator::}{Acceptable}. The user may change the content to any \l{QValidator::}{Intermediate} value during editing, but will be prevented from editing the text to a value that v validates as \l{QValidator::}{Invalid}.

This allows you to constrain the text that shall finally be entered when editing is done, while leaving users with enough freedom to edit the text from one valid state to another.

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(), hasAcceptableInput(), QIntValidator, QDoubleValidator, QRegularExpressionValidator

Definition at line 622 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ sizeHint()

QSize QLineEdit::sizeHint ( ) const
overridevirtual

Returns a recommended size for the widget.

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

Reimplemented from QWidget.

Definition at line 690 of file qlineedit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ text()

QString QLineEdit::text ( ) const

Definition at line 310 of file qlineedit.cpp.

Here is the caller graph for this function:

◆ textChanged

void QLineEdit::textChanged ( const QString text)
signal

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

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

Here is the caller graph for this function:

◆ textEdited

void QLineEdit::textEdited ( const QString text)
signal

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

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

Here is the caller graph for this function:

◆ textMargins()

QMargins QLineEdit::textMargins ( ) const
Since
4.6 Returns the widget's text margins.
See also
setTextMargins()

Definition at line 1166 of file qlineedit.cpp.

◆ timerEvent()

void QLineEdit::timerEvent ( QTimerEvent e)
overridevirtual

\reimp

Reimplemented from QObject.

Definition at line 1442 of file qlineedit.cpp.

◆ undo

void QLineEdit::undo ( )
slot

Undoes the last operation if undo is \l{QLineEdit::undoAvailable}{available}. Deselects any current selection, and updates the selection start to the current cursor position.

Definition at line 1325 of file qlineedit.cpp.

◆ validator()

const QValidator * QLineEdit::validator ( ) const

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

See also
setValidator()

Definition at line 596 of file qlineedit.cpp.

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ QAbstractSpinBox

friend class QAbstractSpinBox
friend

Definition at line 245 of file qlineedit.h.

◆ QAccessibleLineEdit

friend class QAccessibleLineEdit
friend

Definition at line 246 of file qlineedit.h.

◆ QComboBox

friend class QComboBox
friend

Definition at line 247 of file qlineedit.h.

Property Documentation

◆ acceptableInput

QLineEdit::acceptableInput
read

whether the input satisfies the inputMask and the validator.

By default, this property is true.

See also
setInputMask(), setValidator()

Definition at line 269 of file qlineedit.h.

◆ alignment

QLineEdit::alignment
readwrite

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

Definition at line 269 of file qlineedit.h.

◆ clearButtonEnabled

QLineEdit::clearButtonEnabled
readwrite

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

See also
addAction(), removeAction()
Since
5.2

Definition at line 269 of file qlineedit.h.

◆ cursorMoveStyle

QLineEdit::cursorMoveStyle
readwrite

the movement style of cursor in this line edit.

Since
4.8

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.

Definition at line 269 of file qlineedit.h.

◆ cursorPosition

QLineEdit::cursorPosition
readwrite

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.

Definition at line 269 of file qlineedit.h.

◆ displayText

QLineEdit::displayText
read

the displayed text.

If \l echoMode is \l Normal this returns the same as text(); if \l EchoMode is \l Password or \l PasswordEchoOnEdit it returns a string of platform-dependent password mask characters text().length() in size, e.g. "******"; if \l EchoMode is \l NoEcho returns an empty string, "".

By default, this property contains an empty string.

See also
setEchoMode(), text(), EchoMode

Definition at line 269 of file qlineedit.h.

◆ dragEnabled

QLineEdit::dragEnabled
readwrite

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

Dragging is disabled by default.

Definition at line 269 of file qlineedit.h.

◆ echoMode

QLineEdit::echoMode
readwrite

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 \l 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 \l NoEcho, \l Password and \l 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 \l Normal.

See also
EchoMode, displayText()

Definition at line 269 of file qlineedit.h.

◆ frame

QLineEdit::frame
readwrite

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.

Definition at line 269 of file qlineedit.h.

◆ hasSelectedText

QLineEdit::hasSelectedText
read

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

Definition at line 269 of file qlineedit.h.

◆ inputMask

QLineEdit::inputMask
readwrite

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

The input mask is an input template string. It can contain the following elements: \table \row

  • Mask Characters
  • Defines the \l {QChar::} {Category} of input characters that are considered valid in this position \row
  • Meta Characters
  • Various special meanings \row
  • Separators
  • All other characters are regarded as immutable separators \endtable

The following table shows the mask and meta characters that can be used in an input mask.

\table \header

  • Mask Character
  • Meaning \row
  • A
  • character of the Letter category required, such as A-Z, a-z. \row
  • a
  • character of the Letter category permitted but not required. \row
  • N
  • character of the Letter or Number category required, such as A-Z, a-z, 0-9. \row
  • n
  • character of the Letter or Number category permitted but not required. \row
  • X
  • Any non-blank character required. \row
  • x
  • Any non-blank character permitted but not required. \row
  • 9
  • character of the Number category required, e.g 0-9. \row
  • 0
  • character of the Number category permitted but not required. \row
  • D
  • character of the Number category and larger than zero required, such as 1-9 \row
  • d
  • character of the Number category and larger than zero permitted but not required, such as 1-9. \row
  • #
  • character of the Number category, or plus/minus sign permitted but not required. \row
  • H
  • Hexadecimal character required. A-F, a-f, 0-9. \row
  • h
  • Hexadecimal character permitted but not required. \row
  • B
  • Binary character required. 0-1. \row
  • b
  • Binary character permitted but not required. \header
  • Meta Character
  • Meaning \row
  • >
  • All following alphabetic characters are uppercased. \row
  • <
  • All following alphabetic characters are lowercased. \row
  • !
  • Switch off case conversion. \row
  • {;c}
  • Terminates the input mask and sets the {blank} character to {c}. \row
  • {[ ] { }}
  • Reserved. \row
  • \tt{\}
  • Use \tt{\} to escape the special characters listed above to use them as separators. \endtable

When created or cleared, the line edit will be filled with a copy of the input mask string where the meta characters have been removed, and the mask characters have been replaced with the {blank} character (by default, a space).

When an input mask is set, the text() method returns a modified copy of the line edit content where all the {blank} characters have been removed. The unmodified content can be read using displayText().

The hasAcceptableInput() method returns false if the current content of the line edit does not fulfil the requirements of the input mask.

Examples: \table \header

  • Mask
  • Notes \row
  • 000.000.000.000;_
  • IP address; blanks are {_}. \row
  • HH:HH:HH:HH:HH:HH;_
  • MAC address \row
  • 0000-00-00
  • ISO Date; blanks are space \row
  • >AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;#
  • License number; blanks are {#} and all (alphabetic) characters are converted to uppercase. \endtable

To get range control (e.g., for an IP address) use masks together with \l{setValidator()}{validators}.

See also
maxLength, QChar::isLetter(), QChar::isNumber(), QChar::digitValue()

Definition at line 269 of file qlineedit.h.

◆ maxLength

QLineEdit::maxLength
readwrite

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

Definition at line 269 of file qlineedit.h.

◆ modified

QLineEdit::modified
readwrite

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.

Definition at line 269 of file qlineedit.h.

◆ placeholderText

QLineEdit::placeholderText
readwrite

the line edit's placeholder text.

Since
4.7

Setting this property makes the line edit display a grayed-out placeholder text as long as the line edit is empty.

Normally, an empty line edit shows the placeholder text even when it has focus. However, if the content is horizontally centered, the placeholder text is not displayed under the cursor when the line edit has focus.

By default, this property contains an empty string.

See also
text()

Definition at line 269 of file qlineedit.h.

◆ readOnly

QLineEdit::readOnly
readwrite

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

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

By default, this property is false.

See also
setEnabled()

Definition at line 269 of file qlineedit.h.

◆ redoAvailable

QLineEdit::redoAvailable
read

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.

Definition at line 269 of file qlineedit.h.

◆ selectedText

QLineEdit::selectedText
read

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

Definition at line 269 of file qlineedit.h.

◆ text

QLineEdit::text
readwrite

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 \l 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()

Definition at line 269 of file qlineedit.h.

◆ undoAvailable

QLineEdit::undoAvailable
read

whether undo is available.

Undo becomes available once the user has modified the text in the line edit.

By default, this property is false.

Definition at line 269 of file qlineedit.h.


The documentation for this class was generated from the following files: