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
qquicktextedit_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 QQUICKTEXTEDIT_P_H
5#define QQUICKTEXTEDIT_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
21#include <QtGui/qtextoption.h>
22
24
25class QTextDocument;
29class QTextBlock;
30
38
39class Q_QUICK_EXPORT QQuickTextEdit : public QQuickImplicitSizeItem, public QQuickTextInterface
40{
43
46 Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged)
47 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor NOTIFY selectedTextColorChanged)
48 Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
49 Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign RESET resetHAlign NOTIFY horizontalAlignmentChanged)
50 Q_PROPERTY(HAlignment effectiveHorizontalAlignment READ effectiveHAlign NOTIFY effectiveHorizontalAlignmentChanged)
51 Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged)
52 Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
53 Q_PROPERTY(int lineCount READ lineCount NOTIFY lineCountChanged)
55 Q_PROPERTY(qreal contentWidth READ contentWidth NOTIFY contentSizeChanged)
56 Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentSizeChanged)
57 Q_PROPERTY(qreal paintedWidth READ contentWidth NOTIFY contentSizeChanged) // Compatibility
58 Q_PROPERTY(qreal paintedHeight READ contentHeight NOTIFY contentSizeChanged)
59 Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
60 Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
61 Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
62 Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
63 Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
64 Q_PROPERTY(QQmlComponent* cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
65 Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode NOTIFY overwriteModeChanged)
66 Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged)
67 Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged)
68 Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged)
69 Q_PROPERTY(bool activeFocusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY activeFocusOnPressChanged)
70 Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged)
71 Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin NOTIFY textMarginChanged)
72 Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged)
73 Q_PROPERTY(bool selectByKeyboard READ selectByKeyboard WRITE setSelectByKeyboard NOTIFY selectByKeyboardChanged REVISION(2, 1))
74 Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged)
75 Q_PROPERTY(SelectionMode mouseSelectionMode READ mouseSelectionMode WRITE setMouseSelectionMode NOTIFY mouseSelectionModeChanged)
76 Q_PROPERTY(bool canPaste READ canPaste NOTIFY canPasteChanged)
77 Q_PROPERTY(bool canUndo READ canUndo NOTIFY canUndoChanged)
78 Q_PROPERTY(bool canRedo READ canRedo NOTIFY canRedoChanged)
79 Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged)
80 Q_PROPERTY(QUrl baseUrl READ baseUrl WRITE setBaseUrl RESET resetBaseUrl NOTIFY baseUrlChanged)
81 Q_PROPERTY(RenderType renderType READ renderType WRITE setRenderType NOTIFY renderTypeChanged)
82 Q_PROPERTY(QQuickTextDocument *textDocument READ textDocument CONSTANT FINAL REVISION(2, 1))
83 Q_PROPERTY(QString hoveredLink READ hoveredLink NOTIFY linkHovered REVISION(2, 2))
84 Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged REVISION(2, 6))
85 Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged REVISION(2, 6))
86 Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged REVISION(2, 6))
87 Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION(2, 6))
88 Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION(2, 6))
89 Q_PROPERTY(QString preeditText READ preeditText NOTIFY preeditTextChanged REVISION(2, 7))
90 Q_PROPERTY(qreal tabStopDistance READ tabStopDistance WRITE setTabStopDistance NOTIFY tabStopDistanceChanged REVISION(2, 10))
91 Q_PROPERTY(QQuickTextSelection* cursorSelection READ cursorSelection REVISION(6, 7) CONSTANT FINAL)
93#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
95#endif
96
97public:
98 QQuickTextEdit(QQuickItem *parent=nullptr);
99 ~QQuickTextEdit() override;
100
102 AlignLeft = Qt::AlignLeft,
103 AlignRight = Qt::AlignRight,
104 AlignHCenter = Qt::AlignHCenter,
105 AlignJustify = Qt::AlignJustify
106 };
107 Q_ENUM(HAlignment)
108
110 AlignTop = Qt::AlignTop,
111 AlignBottom = Qt::AlignBottom,
112 AlignVCenter = Qt::AlignVCenter
113 };
114 Q_ENUM(VAlignment)
115
117 PlainText = Qt::PlainText,
118 RichText = Qt::RichText,
119 AutoText = Qt::AutoText,
120 MarkdownText = Qt::MarkdownText
121 };
122 Q_ENUM(TextFormat)
123
127 WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere, // COMPAT
129 };
130 Q_ENUM(WrapMode)
131
134 SelectWords
135 };
136 Q_ENUM(SelectionMode)
137
140 CurveRendering
141 };
142 Q_ENUM(RenderType)
143
144 QString text() const;
145 void setText(const QString &);
146
147 Q_REVISION(2, 7) QString preeditText() const;
148
149 TextFormat textFormat() const;
150 void setTextFormat(TextFormat format);
151
152 QFont font() const;
153 void setFont(const QFont &font);
154
155 QColor color() const;
156 void setColor(const QColor &c);
157
158 QColor selectionColor() const;
159 void setSelectionColor(const QColor &c);
160
161 QColor selectedTextColor() const;
162 void setSelectedTextColor(const QColor &c);
163
164 HAlignment hAlign() const;
165 void setHAlign(HAlignment align);
166 void resetHAlign();
167 HAlignment effectiveHAlign() const;
168
169 VAlignment vAlign() const;
170 void setVAlign(VAlignment align);
171
172 WrapMode wrapMode() const;
173 void setWrapMode(WrapMode w);
174
175 int lineCount() const;
176
177 int length() const;
178
179 bool isCursorVisible() const;
180 void setCursorVisible(bool on);
181
182 int cursorPosition() const;
183 void setCursorPosition(int pos);
184
185 QQmlComponent* cursorDelegate() const;
186 void setCursorDelegate(QQmlComponent*);
187
188 bool overwriteMode() const;
189 void setOverwriteMode(bool overwrite);
190
191 int selectionStart() const;
192 int selectionEnd() const;
193
194 QString selectedText() const;
195
196 bool focusOnPress() const;
197 void setFocusOnPress(bool on);
198
199 bool persistentSelection() const;
200 void setPersistentSelection(bool on);
201
202 qreal textMargin() const;
203 void setTextMargin(qreal margin);
204
205 Qt::InputMethodHints inputMethodHints() const;
206 void setInputMethodHints(Qt::InputMethodHints hints);
207
208 bool selectByKeyboard() const;
209 void setSelectByKeyboard(bool);
210
211 bool selectByMouse() const;
212 void setSelectByMouse(bool);
213
214 SelectionMode mouseSelectionMode() const;
215 void setMouseSelectionMode(SelectionMode mode);
216
217 bool canPaste() const;
218
219 bool canUndo() const;
220 bool canRedo() const;
221
222 void componentComplete() override;
223
224 int resourcesLoading() const; // mainly for testing
225
226 /* FROM EDIT */
227 void setReadOnly(bool);
228 bool isReadOnly() const;
229
230 QRectF cursorRectangle() const;
231
232#if QT_CONFIG(im)
233 QVariant inputMethodQuery(Qt::InputMethodQuery property) const override;
234 Q_REVISION(2, 4) Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const;
235#endif
236
237 qreal contentWidth() const;
238 qreal contentHeight() const;
239
240 QUrl baseUrl() const;
241 void setBaseUrl(const QUrl &url);
242 void resetBaseUrl();
243
244 Q_INVOKABLE QRectF positionToRectangle(int) const;
245 Q_INVOKABLE int positionAt(qreal x, qreal y) const;
246 Q_INVOKABLE void moveCursorSelection(int pos);
247 Q_INVOKABLE void moveCursorSelection(int pos, SelectionMode mode);
248
249 QQuickTextSelection *cursorSelection() const;
250
251 QRectF boundingRect() const override;
252 QRectF clipRect() const override;
253
254 bool isInputMethodComposing() const;
255
256 RenderType renderType() const;
257 void setRenderType(RenderType renderType);
258
259 Q_INVOKABLE QString getText(int start, int end) const;
260 Q_INVOKABLE QString getFormattedText(int start, int end) const;
261
263
264 QString hoveredLink() const;
265
267
268 qreal padding() const;
269 void setPadding(qreal padding);
270 void resetPadding();
271
272 qreal topPadding() const;
273 void setTopPadding(qreal padding);
274 void resetTopPadding();
275
276 qreal leftPadding() const;
277 void setLeftPadding(qreal padding);
278 void resetLeftPadding();
279
280 qreal rightPadding() const;
281 void setRightPadding(qreal padding);
282 void resetRightPadding();
283
284 qreal bottomPadding() const;
285 void setBottomPadding(qreal padding);
286 void resetBottomPadding();
287
288 int tabStopDistance() const;
289 void setTabStopDistance(qreal distance);
290
291 void invalidate() override;
292
295 Q_REVISION(2, 7) void preeditTextChanged();
296 void contentSizeChanged();
297 void cursorPositionChanged();
298 void cursorRectangleChanged();
299 void selectionStartChanged();
300 void selectionEndChanged();
301 void selectedTextChanged();
303 void selectionColorChanged(const QColor &color);
304 void selectedTextColorChanged(const QColor &color);
305 void fontChanged(const QFont &font);
306 void horizontalAlignmentChanged(QQuickTextEdit::HAlignment alignment);
307 void verticalAlignmentChanged(QQuickTextEdit::VAlignment alignment);
308 void wrapModeChanged();
309 void lineCountChanged();
310 void textFormatChanged(QQuickTextEdit::TextFormat textFormat);
311 void readOnlyChanged(bool isReadOnly);
312 void cursorVisibleChanged(bool isCursorVisible);
313 void cursorDelegateChanged();
314 void overwriteModeChanged(bool overwriteMode);
315 void activeFocusOnPressChanged(bool activeFocusOnPressed);
316 void persistentSelectionChanged(bool isPersistentSelection);
317 void textMarginChanged(qreal textMargin);
318 Q_REVISION(2, 1) void selectByKeyboardChanged(bool selectByKeyboard);
319 void selectByMouseChanged(bool selectByMouse);
320 void mouseSelectionModeChanged(QQuickTextEdit::SelectionMode mode);
321 void linkActivated(const QString &link);
322 Q_REVISION(2, 2) void linkHovered(const QString &link);
323 void canPasteChanged();
324 void canUndoChanged();
325 void canRedoChanged();
326 void inputMethodComposingChanged();
327 void effectiveHorizontalAlignmentChanged();
328 void baseUrlChanged();
329 void inputMethodHintsChanged();
330 void renderTypeChanged();
331 Q_REVISION(2, 6) void editingFinished();
332 Q_REVISION(2, 6) void paddingChanged();
333 Q_REVISION(2, 6) void topPaddingChanged();
334 Q_REVISION(2, 6) void leftPaddingChanged();
335 Q_REVISION(2, 6) void rightPaddingChanged();
336 Q_REVISION(2, 6) void bottomPaddingChanged();
337 Q_REVISION(2, 10) void tabStopDistanceChanged(qreal distance);
338
339public Q_SLOTS:
340 void selectAll();
341 void selectWord();
342 void select(int start, int end);
343 void deselect();
344 bool isRightToLeft(int start, int end);
345#if QT_CONFIG(clipboard)
346 void cut();
347 void copy();
348 void paste();
349#endif
350 void undo();
351 void redo();
352 void insert(int position, const QString &text);
353 void remove(int start, int end);
355 Q_REVISION(2, 7) void clear();
356
358 void q_invalidate();
359 void q_textChanged();
360 void q_contentsChange(int, int, int);
361 void updateSelection();
362 void moveCursorDelegate();
363 void createCursor();
364 void q_canPasteChanged();
365 void updateWholeDocument();
366 void invalidateBlock(const QTextBlock &block);
367 void updateCursor();
368 void q_linkHovered(const QString &link);
369 void q_markerHovered(bool hovered);
370 void q_updateAlignment();
371 void updateSize();
372 void triggerPreprocess();
373 Q_REVISION(6, 7) QVariant loadResource(int type, const QUrl &source);
374 void resourceRequestFinished();
375
376private:
377 void markDirtyNodesForRange(int start, int end, int charDelta);
378 void updateTotalLines();
379 void invalidateFontCaches();
380 QTextDocument* document() const;
381 void setDocument(QTextDocument *doc);
382
383protected:
384 QQuickTextEdit(QQuickTextEditPrivate &dd, QQuickItem *parent = nullptr);
385#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
386 void setOldSelectionDefault();
387#endif
388
389 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
390 void itemChange(ItemChange change, const ItemChangeData &value) override;
391
392 bool event(QEvent *) override;
393 void keyPressEvent(QKeyEvent *) override;
394 void keyReleaseEvent(QKeyEvent *) override;
395 void focusInEvent(QFocusEvent *event) override;
396 void focusOutEvent(QFocusEvent *event) override;
397
398 void hoverEnterEvent(QHoverEvent *event) override;
399 void hoverMoveEvent(QHoverEvent *event) override;
400 void hoverLeaveEvent(QHoverEvent *event) override;
401
402 // mouse filter?
403 void mousePressEvent(QMouseEvent *event) override;
404 void mouseReleaseEvent(QMouseEvent *event) override;
405 void mouseDoubleClickEvent(QMouseEvent *event) override;
406 void mouseMoveEvent(QMouseEvent *event) override;
407#if QT_CONFIG(im)
408 void inputMethodEvent(QInputMethodEvent *e) override;
409#endif
410 QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
411 void updatePolish() override;
412
413 friend class QQuickTextUtil;
415
416private:
417 Q_DISABLE_COPY(QQuickTextEdit)
418 Q_DECLARE_PRIVATE(QQuickTextEdit)
419};
420
421#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
422class QQuickPre64TextEdit : public QQuickTextEdit {
427public:
428 QQuickPre64TextEdit(QQuickItem *parent = nullptr);
429};
430#endif
431
433
435
436#endif // QQUICKTEXTEDIT_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
\inmodule QtGui
Definition qevent.h:246
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
\qmltype TextDocument \instantiates QQuickTextDocument \inqmlmodule QtQuick
Q_REVISION(2, 2) void append(const QString &text)
Q_REVISION(2, 7) QString preeditText() const
QQuickTextDocument * textDocument()
\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
\reentrant
\reentrant \inmodule QtGui
@ WrapAtWordBoundaryOrAnywhere
Definition qtextoption.h:65
\inmodule QtCore
Definition qurl.h:94
\inmodule QtCore
Definition qvariant.h:65
b clear()
QString text
void colorChanged()
void textChanged(const QString &newText)
list append(new Employee("Blackpool", "Stephen"))
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
@ AlignJustify
Definition qnamespace.h:149
@ 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
@ RichText
@ MarkdownText
@ PlainText
@ AutoText
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]
#define Q_DECLARE_MIXED_ENUM_OPERATORS_SYMMETRIC(Ret, Flags, Enum)
Definition qflags.h:247
GLint GLint GLint GLint GLint x
[0]
GLenum mode
GLfloat GLfloat GLfloat w
[0]
GLuint GLuint end
GLenum GLuint GLenum GLsizei length
GLsizei GLsizei GLfloat distance
GLuint color
[2]
GLenum type
GLuint start
GLint GLsizei GLsizei GLenum format
GLint y
GLsizei GLsizei GLchar * source
struct _cl_event * event
GLenum query
const GLubyte * c
static const QRectF boundingRect(const QPointF *points, int pointCount)
#define QML_ANONYMOUS
#define QML_EXTENDED(EXTENDED_TYPE)
#define QML_NAMED_ELEMENT(NAME)
#define QML_REMOVED_IN_VERSION(MAJOR, MINOR)
#define QML_FOREIGN(FOREIGN_TYPE)
#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_GADGET
#define Q_SIGNALS
double qreal
Definition qtypes.h:187
const char property[13]
Definition qwizard.cpp:101
settings remove("monkey")
QUrl url("example.com")
[constructor-url-reference]
QUrl baseUrl
myFilter setColor(QColor(128, 0, 0))
selection select(topLeft, bottomRight)
insertRed setText("insert red text")
stack undo()
QDBusArgument argument
\inmodule QtQuick
Definition qquickitem.h:159