Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquicktextinput_p.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
4#ifndef QQUICKTEXTINPUT_P_H
5#define QQUICKTEXTINPUT_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
20#include <QtGui/qtextoption.h>
21#if QT_CONFIG(validator)
22#include <QtGui/qvalidator.h>
23#endif
24
26
28class Q_QUICK_EXPORT QQuickTextInput : public QQuickImplicitSizeItem, public QQuickTextInterface
29{
32
36 Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged)
37 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor NOTIFY selectedTextColorChanged)
38 Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
39 Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign RESET resetHAlign NOTIFY horizontalAlignmentChanged)
40 Q_PROPERTY(HAlignment effectiveHorizontalAlignment READ effectiveHAlign NOTIFY effectiveHorizontalAlignmentChanged)
41 Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged)
42 Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
43
44 Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
45 Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
46 Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
47 Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
48 Q_PROPERTY(QQmlComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
49 Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode NOTIFY overwriteModeChanged)
50 Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged)
51 Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged)
52 Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged)
53
54 Q_PROPERTY(int maximumLength READ maxLength WRITE setMaxLength NOTIFY maximumLengthChanged)
55#if QT_CONFIG(validator)
56 Q_PROPERTY(QValidator* validator READ validator WRITE setValidator NOTIFY validatorChanged)
57#endif
58 Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask NOTIFY inputMaskChanged)
59 Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged)
60
61 Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged)
62 Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode NOTIFY echoModeChanged)
63 Q_PROPERTY(bool activeFocusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY activeFocusOnPressChanged)
64 Q_PROPERTY(QString passwordCharacter READ passwordCharacter WRITE setPasswordCharacter NOTIFY passwordCharacterChanged)
65 Q_PROPERTY(int passwordMaskDelay READ passwordMaskDelay WRITE setPasswordMaskDelay RESET resetPasswordMaskDelay NOTIFY passwordMaskDelayChanged REVISION(2, 4))
66 Q_PROPERTY(QString displayText READ displayText NOTIFY displayTextChanged)
67 Q_PROPERTY(QString preeditText READ preeditText NOTIFY preeditTextChanged REVISION(2, 7))
68 Q_PROPERTY(bool autoScroll READ autoScroll WRITE setAutoScroll NOTIFY autoScrollChanged)
69 Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged)
70 Q_PROPERTY(SelectionMode mouseSelectionMode READ mouseSelectionMode WRITE setMouseSelectionMode NOTIFY mouseSelectionModeChanged)
71 Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged)
72 Q_PROPERTY(bool canPaste READ canPaste NOTIFY canPasteChanged)
73 Q_PROPERTY(bool canUndo READ canUndo NOTIFY canUndoChanged)
74 Q_PROPERTY(bool canRedo READ canRedo NOTIFY canRedoChanged)
75 Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged)
76 Q_PROPERTY(qreal contentWidth READ contentWidth NOTIFY contentSizeChanged)
77 Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentSizeChanged)
78 Q_PROPERTY(RenderType renderType READ renderType WRITE setRenderType NOTIFY renderTypeChanged)
79
80 Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged REVISION(2, 6))
81 Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged REVISION(2, 6))
82 Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged REVISION(2, 6))
83 Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION(2, 6))
84 Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION(2, 6))
85 QML_NAMED_ELEMENT(TextInput)
87#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
89#endif
90
91public:
92 QQuickTextInput(QQuickItem * parent=nullptr);
94
95 void componentComplete() override;
96
97 enum EchoMode {//To match QLineEdit::EchoMode
101 PasswordEchoOnEdit
102 };
103 Q_ENUM(EchoMode)
104
106 AlignLeft = Qt::AlignLeft,
107 AlignRight = Qt::AlignRight,
108 AlignHCenter = Qt::AlignHCenter
109 };
110 Q_ENUM(HAlignment)
111
113 AlignTop = Qt::AlignTop,
114 AlignBottom = Qt::AlignBottom,
115 AlignVCenter = Qt::AlignVCenter
116 };
117 Q_ENUM(VAlignment)
118
126 Q_ENUM(WrapMode)
127
130 SelectWords
131 };
132 Q_ENUM(SelectionMode)
133
136 CursorOnCharacter
137 };
138 Q_ENUM(CursorPosition)
139
142 CurveRendering
143 };
144 Q_ENUM(RenderType)
145
146 //Auxilliary functions needed to control the TextInput from QML
148 Q_INVOKABLE QRectF positionToRectangle(int pos) const;
149 Q_INVOKABLE void moveCursorSelection(int pos);
150 Q_INVOKABLE void moveCursorSelection(int pos, SelectionMode mode);
151
152 RenderType renderType() const;
153 void setRenderType(RenderType renderType);
154
155 QString text() const;
156 void setText(const QString &);
157
158 int length() const;
159
160 QFont font() const;
161 void setFont(const QFont &font);
162
163 QColor color() const;
164 void setColor(const QColor &c);
165
166 QColor selectionColor() const;
167 void setSelectionColor(const QColor &c);
168
169 QColor selectedTextColor() const;
170 void setSelectedTextColor(const QColor &c);
171
172 HAlignment hAlign() const;
173 void setHAlign(HAlignment align);
174 void resetHAlign();
175 HAlignment effectiveHAlign() const;
176
177 VAlignment vAlign() const;
178 void setVAlign(VAlignment align);
179
180 WrapMode wrapMode() const;
181 void setWrapMode(WrapMode w);
182
183 bool isReadOnly() const;
184 void setReadOnly(bool);
185
186 bool isCursorVisible() const;
187 void setCursorVisible(bool on);
188
189 int cursorPosition() const;
190 void setCursorPosition(int cp);
191
192 QRectF cursorRectangle() const;
193
194 int selectionStart() const;
195 int selectionEnd() const;
196
197 QString selectedText() const;
198
199 int maxLength() const;
200 void setMaxLength(int ml);
201
202#if QT_CONFIG(validator)
203 QValidator * validator() const;
204 void setValidator(QValidator* v);
205#endif
206
207 QString inputMask() const;
208 void setInputMask(const QString &im);
209
210 EchoMode echoMode() const;
211 void setEchoMode(EchoMode echo);
212
213 QString passwordCharacter() const;
214 void setPasswordCharacter(const QString &str);
215
216 int passwordMaskDelay() const;
217 void setPasswordMaskDelay(int delay);
218 void resetPasswordMaskDelay();
219
220 QString displayText() const;
221 Q_REVISION(2, 7) QString preeditText() const;
222
223 QQmlComponent* cursorDelegate() const;
224 void setCursorDelegate(QQmlComponent*);
225
226 bool overwriteMode() const;
227 void setOverwriteMode(bool overwrite);
228
229 bool focusOnPress() const;
230 void setFocusOnPress(bool);
231
232 bool autoScroll() const;
233 void setAutoScroll(bool);
234
235 bool selectByMouse() const;
236 void setSelectByMouse(bool);
237
238 SelectionMode mouseSelectionMode() const;
239 void setMouseSelectionMode(SelectionMode mode);
240
241 bool persistentSelection() const;
242 void setPersistentSelection(bool persist);
243
244 bool hasAcceptableInput() const;
245
246#if QT_CONFIG(im)
247 QVariant inputMethodQuery(Qt::InputMethodQuery property) const override;
248 Q_REVISION(2, 4) Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, const QVariant &argument) const;
249#endif
250
251 QRectF boundingRect() const override;
252 QRectF clipRect() const override;
253
254 bool canPaste() const;
255
256 bool canUndo() const;
257 bool canRedo() const;
258
259 bool isInputMethodComposing() const;
260
261 Qt::InputMethodHints inputMethodHints() const;
262 void setInputMethodHints(Qt::InputMethodHints hints);
263
264 Q_INVOKABLE QString getText(int start, int end) const;
265
266 qreal contentWidth() const;
267 qreal contentHeight() const;
268
269 qreal padding() const;
270 void setPadding(qreal padding);
271 void resetPadding();
272
273 qreal topPadding() const;
274 void setTopPadding(qreal padding);
275 void resetTopPadding();
276
277 qreal leftPadding() const;
278 void setLeftPadding(qreal padding);
279 void resetLeftPadding();
280
281 qreal rightPadding() const;
282 void setRightPadding(qreal padding);
283 void resetRightPadding();
284
285 qreal bottomPadding() const;
286 void setBottomPadding(qreal padding);
287 void resetBottomPadding();
288
289 void invalidate() override;
290
298 void accepted();
300 Q_REVISION(2, 2) void editingFinished();
301 Q_REVISION(2, 9) void textEdited();
303 void selectionColorChanged();
304 void selectedTextColorChanged();
305 void fontChanged(const QFont &font);
306 void horizontalAlignmentChanged(QQuickTextInput::HAlignment alignment);
307 void verticalAlignmentChanged(QQuickTextInput::VAlignment alignment);
308 void wrapModeChanged();
309 void readOnlyChanged(bool isReadOnly);
310 void cursorVisibleChanged(bool isCursorVisible);
311 void cursorDelegateChanged();
312 void overwriteModeChanged(bool overwriteMode);
313 void maximumLengthChanged(int maximumLength);
314#if QT_CONFIG(validator)
315 void validatorChanged();
316#endif
317 void inputMaskChanged(const QString &inputMask);
320 Q_REVISION(2, 4) void passwordMaskDelayChanged(int delay);
321 void displayTextChanged();
322 Q_REVISION(2, 7) void preeditTextChanged();
323 void activeFocusOnPressChanged(bool activeFocusOnPress);
324 void autoScrollChanged(bool autoScroll);
325 void selectByMouseChanged(bool selectByMouse);
326 void mouseSelectionModeChanged(QQuickTextInput::SelectionMode mode);
327 void persistentSelectionChanged();
328 void canPasteChanged();
329 void canUndoChanged();
330 void canRedoChanged();
331 void inputMethodComposingChanged();
332 void effectiveHorizontalAlignmentChanged();
333 void contentSizeChanged();
334 void inputMethodHintsChanged();
335 void renderTypeChanged();
336 Q_REVISION(2, 6) void paddingChanged();
337 Q_REVISION(2, 6) void topPaddingChanged();
338 Q_REVISION(2, 6) void leftPaddingChanged();
339 Q_REVISION(2, 6) void rightPaddingChanged();
340 Q_REVISION(2, 6) void bottomPaddingChanged();
341
342private:
343 void invalidateFontCaches();
344 void ensureActiveFocus(Qt::FocusReason reason);
345
346protected:
347 QQuickTextInput(QQuickTextInputPrivate &dd, QQuickItem *parent = nullptr);
348#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
349 void setOldSelectionDefault();
350#endif
351
352 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
353 void itemChange(ItemChange change, const ItemChangeData &value) override;
354
355 void mousePressEvent(QMouseEvent *event) override;
356 void mouseMoveEvent(QMouseEvent *event) override;
357 void mouseReleaseEvent(QMouseEvent *event) override;
358 void mouseDoubleClickEvent(QMouseEvent *event) override;
359 void keyPressEvent(QKeyEvent* ev) override;
360#if QT_CONFIG(im)
361 void inputMethodEvent(QInputMethodEvent *) override;
362#endif
363 void mouseUngrabEvent() override;
364 bool event(QEvent *e) override;
365 void focusOutEvent(QFocusEvent *event) override;
366 void focusInEvent(QFocusEvent *event) override;
367 void timerEvent(QTimerEvent *event) override;
368 QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override;
369 void updatePolish() override;
370
371public Q_SLOTS:
372 void selectAll();
373 void selectWord();
374 void select(int start, int end);
375 void deselect();
376 bool isRightToLeft(int start, int end);
377#if QT_CONFIG(clipboard)
378 void cut();
379 void copy();
380 void paste();
381#endif
382 void undo();
383 void redo();
384 void insert(int position, const QString &text);
385 void remove(int start, int end);
386 Q_REVISION(2, 4) void ensureVisible(int position);
387 Q_REVISION(2, 7) void clear();
388
390 void selectionChanged();
391 void createCursor();
392 void updateCursorRectangle(bool scroll = true);
393 void q_canPasteChanged();
394 void q_updateAlignment();
395 void triggerPreprocess();
396
397#if QT_CONFIG(validator)
398 void q_validatorChanged();
399#endif
400
401private:
402 friend class QQuickTextUtil;
403
404 Q_DECLARE_PRIVATE(QQuickTextInput)
405};
406
407#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
408class QQuickPre64TextInput : public QQuickTextInput {
410 QML_NAMED_ELEMENT(TextInput)
413public:
414 QQuickPre64TextInput(QQuickItem *parent = nullptr);
415};
416#endif
417
419
420#endif // QQUICKTEXTINPUT_P_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore
Definition qcoreevent.h:45
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:470
\reentrant
Definition qfont.h:22
The QInputMethodEvent class provides parameters for input method events.
Definition qevent.h:625
The QKeyEvent class describes a key event.
Definition qevent.h:424
\inmodule QtGui
Definition qevent.h:196
The QQmlComponent class encapsulates a QML component definition.
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
Definition qquickitem.h:144
void cursorPositionChanged()
Q_REVISION(2, 4) void passwordMaskDelayChanged(int delay)
void passwordCharacterChanged()
Q_REVISION(2, 7) QString preeditText() const
void selectedTextChanged()
void echoModeChanged(QQuickTextInput::EchoMode echoMode)
void cursorRectangleChanged()
Q_REVISION(2, 2) void editingFinished()
Q_REVISION(2, 4) void ensureVisible(int position)
void acceptableInputChanged()
void inputMaskChanged(const QString &inputMask)
void selectionEndChanged()
void selectionStartChanged()
\inmodule QtCore\reentrant
Definition qrect.h:484
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
@ WrapAtWordBoundaryOrAnywhere
Definition qtextoption.h:65
\inmodule QtCore
Definition qcoreevent.h:366
The QValidator class provides validation of input text.
Definition qvalidator.h:24
\inmodule QtCore
Definition qvariant.h:65
QString str
[2]
b clear()
QString text
void colorChanged()
void textChanged(const QString &newText)
cache insert(employee->id(), employee)
uint alignment
Combined button and popup list for selecting options.
Definition qcompare.h:63
InputMethodQuery
@ AlignRight
Definition qnamespace.h:146
@ AlignBottom
Definition qnamespace.h:154
@ AlignVCenter
Definition qnamespace.h:155
@ AlignTop
Definition qnamespace.h:153
@ AlignHCenter
Definition qnamespace.h:148
@ AlignLeft
Definition qnamespace.h:144
static jboolean cut(JNIEnv *, jobject)
static jboolean copy(JNIEnv *, jobject)
static jboolean paste(JNIEnv *, jobject)
static jboolean selectAll(JNIEnv *, jobject)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLsizei const GLfloat * v
[13]
GLenum mode
GLfloat GLfloat GLfloat w
[0]
GLuint GLuint end
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint color
[2]
GLuint start
struct _cl_event * event
GLenum query
const GLubyte * c
GLsizei maxLength
static const QRectF boundingRect(const QPointF *points, int pointCount)
#define QML_NAMED_ELEMENT(NAME)
#define QML_REMOVED_IN_VERSION(MAJOR, MINOR)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static qreal positionAt(const QQuickRangeSlider *slider, QQuickItem *handle, const QPointF &point)
static void getText(QString &text, QTextDocumentPrivate *priv, const QString &docText, int pos, int end)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_REVISION(...)
#define Q_INVOKABLE
#define Q_INTERFACES(x)
#define Q_SLOTS
#define Q_SIGNALS
double qreal
Definition qtypes.h:187
const char property[13]
Definition qwizard.cpp:101
settings remove("monkey")
myFilter setColor(QColor(128, 0, 0))
selection select(topLeft, bottomRight)
insertRed setText("insert red text")
stack undo()
QDBusArgument argument
QJSValueList args
\inmodule QtQuick
Definition qquickitem.h:159