Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qlineedit.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QLINEEDIT_H
6#define QLINEEDIT_H
7
8#include <QtWidgets/qtwidgetsglobal.h>
9#include <QtWidgets/qframe.h>
10#include <QtGui/qtextcursor.h>
11#include <QtCore/qstring.h>
12#include <QtCore/qmargins.h>
13
15
16QT_BEGIN_NAMESPACE
17
18class QValidator;
19class QMenu;
20class QLineEditPrivate;
21class QCompleter;
22class QStyleOptionFrame;
23class QAbstractSpinBox;
24class QDateTimeEdit;
25class QIcon;
26class QToolButton;
27
28class Q_WIDGETS_EXPORT QLineEdit : public QWidget
29{
30 Q_OBJECT
31
32 Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask)
33 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged USER true)
34 Q_PROPERTY(int maxLength READ maxLength WRITE setMaxLength)
35 Q_PROPERTY(bool frame READ hasFrame WRITE setFrame)
36 Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode)
37 Q_PROPERTY(QString displayText READ displayText)
38 Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition)
39 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
40 Q_PROPERTY(bool modified READ isModified WRITE setModified DESIGNABLE false)
41 Q_PROPERTY(bool hasSelectedText READ hasSelectedText)
42 Q_PROPERTY(QString selectedText READ selectedText)
43 Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled)
44 Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
45 Q_PROPERTY(bool undoAvailable READ isUndoAvailable)
46 Q_PROPERTY(bool redoAvailable READ isRedoAvailable)
47 Q_PROPERTY(bool acceptableInput READ hasAcceptableInput)
48 Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
49 Q_PROPERTY(Qt::CursorMoveStyle cursorMoveStyle READ cursorMoveStyle WRITE setCursorMoveStyle)
50 Q_PROPERTY(bool clearButtonEnabled READ isClearButtonEnabled WRITE setClearButtonEnabled)
51public:
52 enum ActionPosition {
53 LeadingPosition,
54 TrailingPosition
55 };
56 Q_ENUM(ActionPosition)
57
58 explicit QLineEdit(QWidget *parent = nullptr);
59 explicit QLineEdit(const QString &, QWidget *parent = nullptr);
60 ~QLineEdit();
61
62 QString text() const;
63
64 QString displayText() const;
65
66 QString placeholderText() const;
67 void setPlaceholderText(const QString &);
68
69 int maxLength() const;
70 void setMaxLength(int);
71
72 void setFrame(bool);
73 bool hasFrame() const;
74
75 void setClearButtonEnabled(bool enable);
76 bool isClearButtonEnabled() const;
77
78 enum EchoMode { Normal, NoEcho, Password, PasswordEchoOnEdit };
79 Q_ENUM(EchoMode)
80 EchoMode echoMode() const;
81 void setEchoMode(EchoMode);
82
83 bool isReadOnly() const;
84 void setReadOnly(bool);
85
86#ifndef QT_NO_VALIDATOR
87 void setValidator(const QValidator *);
88 const QValidator * validator() const;
89#endif
90
91#if QT_CONFIG(completer)
92 void setCompleter(QCompleter *completer);
93 QCompleter *completer() const;
94#endif
95
96 QSize sizeHint() const override;
97 QSize minimumSizeHint() const override;
98
99 int cursorPosition() const;
100 void setCursorPosition(int);
101 int cursorPositionAt(const QPoint &pos);
102
103 void setAlignment(Qt::Alignment flag);
104 Qt::Alignment alignment() const;
105
106 void cursorForward(bool mark, int steps = 1);
107 void cursorBackward(bool mark, int steps = 1);
108 void cursorWordForward(bool mark);
109 void cursorWordBackward(bool mark);
110 void backspace();
111 void del();
112 void home(bool mark);
113 void end(bool mark);
114
115 bool isModified() const;
116 void setModified(bool);
117
118 void setSelection(int, int);
119 bool hasSelectedText() const;
120 QString selectedText() const;
121 int selectionStart() const;
122 int selectionEnd() const;
123 int selectionLength() const;
124
125 bool isUndoAvailable() const;
126 bool isRedoAvailable() const;
127
128 void setDragEnabled(bool b);
129 bool dragEnabled() const;
130
131 void setCursorMoveStyle(Qt::CursorMoveStyle style);
132 Qt::CursorMoveStyle cursorMoveStyle() const;
133
134 QString inputMask() const;
135 void setInputMask(const QString &inputMask);
136 bool hasAcceptableInput() const;
137
138 void setTextMargins(int left, int top, int right, int bottom);
139 void setTextMargins(const QMargins &margins);
140 QMargins textMargins() const;
141
142#if QT_CONFIG(action)
143 using QWidget::addAction;
144 void addAction(QAction *action, ActionPosition position);
145 QAction *addAction(const QIcon &icon, ActionPosition position);
146#endif
147
148public Q_SLOTS:
149 void setText(const QString &);
150 void clear();
151 void selectAll();
152 void undo();
153 void redo();
154#ifndef QT_NO_CLIPBOARD
155 void cut();
156 void copy() const;
157 void paste();
158#endif
159
160public:
161 void deselect();
162 void insert(const QString &);
163#ifndef QT_NO_CONTEXTMENU
164 QMenu *createStandardContextMenu();
165#endif
166
167Q_SIGNALS:
168 void textChanged(const QString &);
169 void textEdited(const QString &);
170 void cursorPositionChanged(int, int);
171 void returnPressed();
172 void editingFinished();
173 void selectionChanged();
174 void inputRejected();
175
176protected:
177 void mousePressEvent(QMouseEvent *) override;
178 void mouseMoveEvent(QMouseEvent *) override;
179 void mouseReleaseEvent(QMouseEvent *) override;
180 void mouseDoubleClickEvent(QMouseEvent *) override;
181 void keyPressEvent(QKeyEvent *) override;
182 void keyReleaseEvent(QKeyEvent *) override;
183 void focusInEvent(QFocusEvent *) override;
184 void focusOutEvent(QFocusEvent *) override;
185 void paintEvent(QPaintEvent *) override;
186#if QT_CONFIG(draganddrop)
187 void dragEnterEvent(QDragEnterEvent *) override;
188 void dragMoveEvent(QDragMoveEvent *e) override;
189 void dragLeaveEvent(QDragLeaveEvent *e) override;
190 void dropEvent(QDropEvent *) override;
191#endif
192 void changeEvent(QEvent *) override;
193#ifndef QT_NO_CONTEXTMENU
194 void contextMenuEvent(QContextMenuEvent *) override;
195#endif
196
197 void inputMethodEvent(QInputMethodEvent *) override;
198 virtual void initStyleOption(QStyleOptionFrame *option) const;
199public:
200 QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
201 Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const;
202 void timerEvent(QTimerEvent *) override;
203 bool event(QEvent *) override;
204protected:
205 QRect cursorRect() const;
206
207public:
208
209private:
210 friend class QAbstractSpinBox;
211 friend class QAccessibleLineEdit;
212 friend class QComboBox;
213#ifdef QT_KEYPAD_NAVIGATION
214 friend class QDateTimeEdit;
215#endif
216 Q_DISABLE_COPY(QLineEdit)
217 Q_DECLARE_PRIVATE(QLineEdit)
218};
219
220QT_END_NAMESPACE
221
222#endif // QLINEEDIT_H
QColor grabScreenColor(const QPoint &p)
bool selectColor(const QColor &color)
void init(const QColor &initial)
void setCurrentAlpha(int a)
QColorPickingEventFilter * colorPickingEventFilter
bool handleColorPickingMouseButtonRelease(QMouseEvent *e)
QColor currentQColor() const
bool handleColorPickingMouseMove(QMouseEvent *e)
void _q_setCustom(int index, QRgb color)
QPushButton * eyeDropperButton
void updateColorLabelText(const QPoint &)
void setCurrentColor(const QColor &color, SetColorMode setColorMode=SetColorAll)
bool isAlphaVisible() const
QVBoxLayout * leftLay
void setCurrentQColor(const QColor &color)
bool canBeNativeDialog() const override
void setCurrentRgbColor(QRgb rgb)
QRgb currentColor() const
void newColorTypedIn(QRgb rgb)
bool handleColorPickingKeyPress(QKeyEvent *e)
void updateColorPicking(const QPoint &pos)
QSharedPointer< QColorDialogOptions > options
void newStandard(int, int)
void setVisible(bool visible) override
QDialogButtonBox * buttons
bool supportsColorPicking() const
QPointer< QObject > receiverToDisconnectOnClose
virtual void initHelper(QPlatformDialogHelper *h) override
QByteArray memberToDisconnectOnClose
QPushButton * addCusBt
void newHsv(int h, int s, int v)
virtual void helperPrepareShow(QPlatformDialogHelper *h) override
QColorLuminancePicker * lp
void newCustom(int, int)
QPlatformColorDialogHelper * platformColorDialogHelper() const
void nextCustom(int, int)
The QColorDialog class provides a dialog widget for specifying colors.
friend class QPainter
\inmodule QtCore\reentrant
Definition qpoint.h:29
\variable QStyleOption::palette
\variable QStyleOptionFocusRect::backgroundColor
QColSpinBox(QWidget *parent)
void paintEvent(QPaintEvent *) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
void mouseMoveEvent(QMouseEvent *) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
void mousePressEvent(QMouseEvent *) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
void paintEvent(QPaintEvent *) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
void mouseMoveEvent(QMouseEvent *) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
QSize sizeHint() const override
void setCrossVisible(bool visible)
void resizeEvent(QResizeEvent *) override
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
void mousePressEvent(QMouseEvent *) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
bool eventFilter(QObject *, QEvent *event) override
Filters events if this object has been installed as an event filter for the watched object.
void applicationStateChanged(Qt::ApplicationState state)
QColorPickingEventFilter(QColorDialogPrivate *dp, QObject *parent)
void mouseReleaseEvent(QMouseEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse release even...
void mousePressEvent(QMouseEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
void mouseMoveEvent(QMouseEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
void paintEvent(QPaintEvent *) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
void setHsv(int h, int s, int v)
void currentColorChanged(const QColor &color)
QColorWell(QWidget *parent, int r, int c, const QRgb *vals)
void paintCellContents(QPainter *, int row, int col, const QRect &) override
void mousePressEvent(QMouseEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
void mouseMoveEvent(QMouseEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
void mouseReleaseEvent(QMouseEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse release even...
friend class QT_PREPEND_NAMESPACE(QUntypedBindable)
void mouseReleaseEvent(QMouseEvent *) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse release even...
void focusOutEvent(QFocusEvent *) override
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) f...
void currentChanged(int row, int col)
int columnAt(int x) const
void updateCell(int row, int column)
void colorChanged(int index, QRgb color)
void paintEvent(QPaintEvent *) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
void mousePressEvent(QMouseEvent *) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
void focusInEvent(QFocusEvent *) override
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus receive...
virtual void setCurrent(int row, int col)
virtual void setSelected(int row, int col)
int rowAt(int y) const
QRect cellGeometry(int row, int column)
virtual void paintCell(QPainter *, int row, int col, const QRect &)
int columnX(int column) const
int rowY(int row) const
QSize sizeHint() const override
virtual void paintCellContents(QPainter *, int row, int col, const QRect &)
void keyPressEvent(QKeyEvent *) override
This event handler, for event event, can be reimplemented in a subclass to receive key press events f...
QString cellContent(int row, int col) const
QtPrivate::QColorShower QColorShower
static void rgb2hsv(QRgb rgb, int &h, int &s, int &v)
QtPrivate::QColorWell QColorWell
static int pHeight
QtPrivate::QWellArray QWellArray
static int pWidth
QtPrivate::QColorPickingEventFilter QColorPickingEventFilter
QtPrivate::QColorLuminancePicker QColorLuminancePicker
QtPrivate::QColorPicker QColorPicker
static const Qt::WindowFlags qcd_DefaultWindowFlags
@ colorColumns
@ standardColorRows
@ customColorRows
QT_REQUIRE_CONFIG(colordialog)
#define qApp
QT_REQUIRE_CONFIG(progressbar)