41class Q_QUICK_EXPORT
QQuickTextEdit :
public QQuickImplicitSizeItem,
public QQuickTextInterface
44 Q_INTERFACES(QQuickTextInterface)
46 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
47 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
48 Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged)
49 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor NOTIFY selectedTextColorChanged)
50 Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
51 Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign RESET resetHAlign NOTIFY horizontalAlignmentChanged)
52 Q_PROPERTY(HAlignment effectiveHorizontalAlignment READ effectiveHAlign NOTIFY effectiveHorizontalAlignmentChanged)
53 Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged)
54 Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
55 Q_PROPERTY(
int lineCount READ lineCount NOTIFY lineCountChanged)
56 Q_PROPERTY(
int length READ length NOTIFY textChanged)
57 Q_PROPERTY(qreal contentWidth READ contentWidth NOTIFY contentSizeChanged)
58 Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentSizeChanged)
59 Q_PROPERTY(qreal paintedWidth READ contentWidth NOTIFY contentSizeChanged)
60 Q_PROPERTY(qreal paintedHeight READ contentHeight NOTIFY contentSizeChanged)
61 Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
62 Q_PROPERTY(
bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
63 Q_PROPERTY(
bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
64 Q_PROPERTY(
int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
65 Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
66 Q_PROPERTY(QQmlComponent* cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
67 Q_PROPERTY(
bool overwriteMode READ overwriteMode WRITE setOverwriteMode NOTIFY overwriteModeChanged)
68 Q_PROPERTY(
int selectionStart READ selectionStart NOTIFY selectionStartChanged)
69 Q_PROPERTY(
int selectionEnd READ selectionEnd NOTIFY selectionEndChanged)
70 Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged)
71 Q_PROPERTY(
bool activeFocusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY activeFocusOnPressChanged)
72 Q_PROPERTY(
bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged)
73 Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin NOTIFY textMarginChanged)
74 Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged)
75 Q_PROPERTY(
bool selectByKeyboard READ selectByKeyboard WRITE setSelectByKeyboard NOTIFY selectByKeyboardChanged REVISION(2, 1))
76 Q_PROPERTY(
bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged)
77 Q_PROPERTY(SelectionMode mouseSelectionMode READ mouseSelectionMode WRITE setMouseSelectionMode NOTIFY mouseSelectionModeChanged)
78 Q_PROPERTY(
bool canPaste READ canPaste NOTIFY canPasteChanged)
79 Q_PROPERTY(
bool canUndo READ canUndo NOTIFY canUndoChanged)
80 Q_PROPERTY(
bool canRedo READ canRedo NOTIFY canRedoChanged)
81 Q_PROPERTY(
bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged)
82 Q_PROPERTY(QUrl baseUrl READ baseUrl WRITE setBaseUrl RESET resetBaseUrl NOTIFY baseUrlChanged)
83 Q_PROPERTY(RenderType renderType READ renderType WRITE setRenderType NOTIFY renderTypeChanged)
84 Q_PROPERTY(QQuickTextDocument *textDocument READ textDocument CONSTANT FINAL REVISION(2, 1))
85 Q_PROPERTY(QString hoveredLink READ hoveredLink NOTIFY linkHovered REVISION(2, 2))
86 Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged REVISION(2, 6))
87 Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged REVISION(2, 6))
88 Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged REVISION(2, 6))
89 Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION(2, 6))
90 Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION(2, 6))
91 Q_PROPERTY(QString preeditText READ preeditText NOTIFY preeditTextChanged REVISION(2, 7))
92 Q_PROPERTY(qreal tabStopDistance READ tabStopDistance WRITE setTabStopDistance NOTIFY tabStopDistanceChanged REVISION(2, 10))
93 Q_PROPERTY(QQuickTextSelection* cursorSelection READ cursorSelection REVISION(6, 7) CONSTANT FINAL)
94 QML_NAMED_ELEMENT(TextEdit)
95#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
96 QML_ADDED_IN_VERSION(6, 4)
100 QQuickTextEdit(QQuickItem *parent=
nullptr);
101 ~QQuickTextEdit() override;
104 AlignLeft = Qt::AlignLeft,
105 AlignRight = Qt::AlignRight,
106 AlignHCenter = Qt::AlignHCenter,
107 AlignJustify = Qt::AlignJustify
112 AlignTop = Qt::AlignTop,
113 AlignBottom = Qt::AlignBottom,
114 AlignVCenter = Qt::AlignVCenter
119 PlainText = Qt::PlainText,
120 RichText = Qt::RichText,
121 AutoText = Qt::AutoText,
122 MarkdownText = Qt::MarkdownText
126 enum WrapMode { NoWrap = QTextOption::NoWrap,
127 WordWrap = QTextOption::WordWrap,
128 WrapAnywhere = QTextOption::WrapAnywhere,
129 WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere,
130 Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere
138 Q_ENUM(SelectionMode)
140 enum RenderType { QtRendering,
146 QString text()
const;
147 void setText(
const QString &);
149 Q_REVISION(2, 7) QString preeditText()
const;
151 TextFormat textFormat()
const;
152 void setTextFormat(TextFormat format);
155 void setFont(
const QFont &font);
157 QColor color()
const;
158 void setColor(
const QColor &c);
160 QColor selectionColor()
const;
161 void setSelectionColor(
const QColor &c);
163 QColor selectedTextColor()
const;
164 void setSelectedTextColor(
const QColor &c);
166 HAlignment hAlign()
const;
167 void setHAlign(HAlignment align);
169 HAlignment effectiveHAlign()
const;
171 VAlignment vAlign()
const;
172 void setVAlign(VAlignment align);
174 WrapMode wrapMode()
const;
175 void setWrapMode(WrapMode w);
177 int lineCount()
const;
181 bool isCursorVisible()
const;
182 void setCursorVisible(
bool on);
184 int cursorPosition()
const;
185 void setCursorPosition(
int pos);
187 QQmlComponent* cursorDelegate()
const;
188 void setCursorDelegate(QQmlComponent*);
190 bool overwriteMode()
const;
191 void setOverwriteMode(
bool overwrite);
193 int selectionStart()
const;
194 int selectionEnd()
const;
196 QString selectedText()
const;
198 bool focusOnPress()
const;
199 void setFocusOnPress(
bool on);
201 bool persistentSelection()
const;
202 void setPersistentSelection(
bool on);
204 qreal textMargin()
const;
205 void setTextMargin(qreal margin);
207 Qt::InputMethodHints inputMethodHints()
const;
208 void setInputMethodHints(Qt::InputMethodHints hints);
210 bool selectByKeyboard()
const;
211 void setSelectByKeyboard(
bool);
213 bool selectByMouse()
const;
214 void setSelectByMouse(
bool);
216 SelectionMode mouseSelectionMode()
const;
217 void setMouseSelectionMode(SelectionMode mode);
219 bool canPaste()
const;
221 bool canUndo()
const;
222 bool canRedo()
const;
224 void componentComplete() override;
226 int resourcesLoading()
const;
229 void setReadOnly(
bool);
230 bool isReadOnly()
const;
232 QRectF cursorRectangle()
const;
235 QVariant inputMethodQuery(Qt::InputMethodQuery property)
const override;
236 Q_REVISION(2, 4) Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument)
const;
239 qreal contentWidth()
const;
240 qreal contentHeight()
const;
242 QUrl baseUrl()
const;
243 void setBaseUrl(
const QUrl &url);
246 Q_INVOKABLE QRectF positionToRectangle(
int)
const;
247 Q_INVOKABLE
int positionAt(qreal x, qreal y)
const;
248 Q_INVOKABLE
void moveCursorSelection(
int pos);
249 Q_INVOKABLE
void moveCursorSelection(
int pos, QQuickTextEdit::SelectionMode mode);
251 QQuickTextSelection *cursorSelection()
const;
253 QRectF boundingRect()
const override;
254 QRectF clipRect()
const override;
256 bool isInputMethodComposing()
const;
258 RenderType renderType()
const;
259 void setRenderType(RenderType renderType);
261 Q_INVOKABLE QString getText(
int start,
int end)
const;
262 Q_INVOKABLE QString getFormattedText(
int start,
int end)
const;
264 QQuickTextDocument *textDocument();
266 QString hoveredLink()
const;
268 Q_REVISION(2, 3) Q_INVOKABLE QString linkAt(qreal x, qreal y)
const;
270 qreal padding()
const;
271 void setPadding(qreal padding);
274 qreal topPadding()
const;
275 void setTopPadding(qreal padding);
276 void resetTopPadding();
278 qreal leftPadding()
const;
279 void setLeftPadding(qreal padding);
280 void resetLeftPadding();
282 qreal rightPadding()
const;
283 void setRightPadding(qreal padding);
284 void resetRightPadding();
286 qreal bottomPadding()
const;
287 void setBottomPadding(qreal padding);
288 void resetBottomPadding();
290 int tabStopDistance()
const;
291 void setTabStopDistance(qreal distance);
293 void invalidate() override;
297 Q_REVISION(2, 7)
void preeditTextChanged();
298 void contentSizeChanged();
299 void cursorPositionChanged();
300 void cursorRectangleChanged();
301 void selectionStartChanged();
302 void selectionEndChanged();
303 void selectedTextChanged();
304 void colorChanged(
const QColor &color);
305 void selectionColorChanged(
const QColor &color);
306 void selectedTextColorChanged(
const QColor &color);
307 void fontChanged(
const QFont &font);
308 void horizontalAlignmentChanged(QQuickTextEdit::HAlignment alignment);
309 void verticalAlignmentChanged(QQuickTextEdit::VAlignment alignment);
310 void wrapModeChanged();
311 void lineCountChanged();
312 void textFormatChanged(QQuickTextEdit::TextFormat textFormat);
313 void readOnlyChanged(
bool isReadOnly);
314 void cursorVisibleChanged(
bool isCursorVisible);
315 void cursorDelegateChanged();
316 void overwriteModeChanged(
bool overwriteMode);
317 void activeFocusOnPressChanged(
bool activeFocusOnPressed);
318 void persistentSelectionChanged(
bool isPersistentSelection);
319 void textMarginChanged(qreal textMargin);
320 Q_REVISION(2, 1)
void selectByKeyboardChanged(
bool selectByKeyboard);
321 void selectByMouseChanged(
bool selectByMouse);
322 void mouseSelectionModeChanged(QQuickTextEdit::SelectionMode mode);
323 void linkActivated(
const QString &link);
324 Q_REVISION(2, 2)
void linkHovered(
const QString &link);
325 void canPasteChanged();
326 void canUndoChanged();
327 void canRedoChanged();
328 void inputMethodComposingChanged();
329 void effectiveHorizontalAlignmentChanged();
330 void baseUrlChanged();
331 void inputMethodHintsChanged();
332 void renderTypeChanged();
333 Q_REVISION(2, 6)
void editingFinished();
334 Q_REVISION(2, 6)
void paddingChanged();
335 Q_REVISION(2, 6)
void topPaddingChanged();
336 Q_REVISION(2, 6)
void leftPaddingChanged();
337 Q_REVISION(2, 6)
void rightPaddingChanged();
338 Q_REVISION(2, 6)
void bottomPaddingChanged();
339 Q_REVISION(2, 10)
void tabStopDistanceChanged(qreal distance);
340 Q_REVISION(6, 9)
void textEdited();
345 void select(
int start,
int end);
347 bool isRightToLeft(
int start,
int end);
348#if QT_CONFIG(clipboard)
355 void insert(
int position,
const QString &text);
356 void remove(
int start,
int end);
357 Q_REVISION(2, 2)
void append(
const QString &text);
358 Q_REVISION(2, 7)
void clear();
362 void q_textChanged();
363 void q_contentsChange(
int,
int,
int);
364 void updateSelection();
365 void moveCursorDelegate();
367 void q_canPasteChanged();
368 void updateWholeDocument();
369 void invalidateBlock(
const QTextBlock &block);
371 void q_linkHovered(
const QString &link);
372 void q_markerHovered(
bool hovered);
373 void q_updateAlignment();
375 void triggerPreprocess();
376 Q_REVISION(6, 7) QVariant loadResource(
int type,
const QUrl &source);
377 void resourceRequestFinished();
380 void markDirtyNodesForRange(
int start,
int end,
int charDelta);
381 void updateTotalLines();
382 void invalidateFontCaches();
383 QTextDocument* document()
const;
384 void setDocument(QTextDocument *doc);
387 QQuickTextEdit(QQuickTextEditPrivate &dd, QQuickItem *parent =
nullptr);
388#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
389 void setOldSelectionDefault();
392 void geometryChange(
const QRectF &newGeometry,
const QRectF &oldGeometry) override;
393 void itemChange(ItemChange change,
const ItemChangeData &value) override;
395 bool event(QEvent *) override;
396 void keyPressEvent(QKeyEvent *) override;
397 void keyReleaseEvent(QKeyEvent *) override;
398 void focusInEvent(QFocusEvent *event) override;
399 void focusOutEvent(QFocusEvent *event) override;
401 void hoverEnterEvent(QHoverEvent *event) override;
402 void hoverMoveEvent(QHoverEvent *event) override;
403 void hoverLeaveEvent(QHoverEvent *event) override;
406 void mousePressEvent(QMouseEvent *event) override;
407 void mouseReleaseEvent(QMouseEvent *event) override;
408 void mouseDoubleClickEvent(QMouseEvent *event) override;
409 void mouseMoveEvent(QMouseEvent *event) override;
410#if QT_VERSION >= QT_VERSION_CHECK(7
, 0
, 0
)
411 bool contextMenuEvent(QContextMenuEvent *event) override;
414 void inputMethodEvent(QInputMethodEvent *e) override;
416 QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
417 void updatePolish() override;
419 friend class QQuickTextUtil;
420 friend class QQuickTextDocumentPrivate;
423 Q_DISABLE_COPY(QQuickTextEdit)
424 Q_DECLARE_PRIVATE(QQuickTextEdit)