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 VIRTUAL)
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(QString hoveredToolTip READ hoveredToolTip NOTIFY hoveredToolTipChanged REVISION(6, 13))
87 Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged REVISION(2, 6))
88 Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged REVISION(2, 6))
89 Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged REVISION(2, 6))
90 Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION(2, 6))
91 Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION(2, 6))
92 Q_PROPERTY(QString preeditText READ preeditText NOTIFY preeditTextChanged REVISION(2, 7))
93 Q_PROPERTY(qreal tabStopDistance READ tabStopDistance WRITE setTabStopDistance NOTIFY tabStopDistanceChanged REVISION(2, 10))
94 Q_PROPERTY(QQuickTextSelection* cursorSelection READ cursorSelection REVISION(6, 7) CONSTANT FINAL)
95 QML_NAMED_ELEMENT(TextEdit)
96#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
97 QML_ADDED_IN_VERSION(6, 4)
101 QQuickTextEdit(QQuickItem *parent=
nullptr);
102 ~QQuickTextEdit() override;
105 AlignLeft = Qt::AlignLeft,
106 AlignRight = Qt::AlignRight,
107 AlignHCenter = Qt::AlignHCenter,
108 AlignJustify = Qt::AlignJustify
113 AlignTop = Qt::AlignTop,
114 AlignBottom = Qt::AlignBottom,
115 AlignVCenter = Qt::AlignVCenter
120 PlainText = Qt::PlainText,
121 RichText = Qt::RichText,
122 AutoText = Qt::AutoText,
123 MarkdownText = Qt::MarkdownText
127 enum WrapMode { NoWrap = QTextOption::NoWrap,
128 WordWrap = QTextOption::WordWrap,
129 WrapAnywhere = QTextOption::WrapAnywhere,
130 WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere,
131 Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere
139 Q_ENUM(SelectionMode)
141 enum RenderType { QtRendering,
147 QString text()
const;
148 void setText(
const QString &);
150 Q_REVISION(2, 7) QString preeditText()
const;
152 TextFormat textFormat()
const;
153 void setTextFormat(TextFormat format);
156 void setFont(
const QFont &font);
158 QColor color()
const;
159 void setColor(
const QColor &c);
161 QColor selectionColor()
const;
162 void setSelectionColor(
const QColor &c);
164 QColor selectedTextColor()
const;
165 void setSelectedTextColor(
const QColor &c);
167 HAlignment hAlign()
const;
168 void setHAlign(HAlignment align);
170 HAlignment effectiveHAlign()
const;
172 VAlignment vAlign()
const;
173 void setVAlign(VAlignment align);
175 WrapMode wrapMode()
const;
176 void setWrapMode(WrapMode w);
178 int lineCount()
const;
182 bool isCursorVisible()
const;
183 void setCursorVisible(
bool on);
185 int cursorPosition()
const;
186 void setCursorPosition(
int pos);
188 QQmlComponent* cursorDelegate()
const;
189 void setCursorDelegate(QQmlComponent*);
191 bool overwriteMode()
const;
192 void setOverwriteMode(
bool overwrite);
194 int selectionStart()
const;
195 int selectionEnd()
const;
197 QString selectedText()
const;
199 bool focusOnPress()
const;
200 void setFocusOnPress(
bool on);
202 bool persistentSelection()
const;
203 void setPersistentSelection(
bool on);
205 qreal textMargin()
const;
206 void setTextMargin(qreal margin);
208 Qt::InputMethodHints inputMethodHints()
const;
209 void setInputMethodHints(Qt::InputMethodHints hints);
211 bool selectByKeyboard()
const;
212 void setSelectByKeyboard(
bool);
214 bool selectByMouse()
const;
215 void setSelectByMouse(
bool);
217 SelectionMode mouseSelectionMode()
const;
218 void setMouseSelectionMode(SelectionMode mode);
220 bool canPaste()
const;
222 bool canUndo()
const;
223 bool canRedo()
const;
225 void componentComplete() override;
227 int resourcesLoading()
const;
230 void setReadOnly(
bool);
231 bool isReadOnly()
const;
233 QRectF cursorRectangle()
const;
236 QVariant inputMethodQuery(Qt::InputMethodQuery property)
const override;
237 Q_REVISION(2, 4) Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument)
const;
240 qreal contentWidth()
const;
241 qreal contentHeight()
const;
243 QUrl baseUrl()
const;
244 void setBaseUrl(
const QUrl &url);
247 Q_INVOKABLE QRectF positionToRectangle(
int)
const;
248 Q_INVOKABLE
int positionAt(qreal x, qreal y)
const;
249 Q_INVOKABLE
void moveCursorSelection(
int pos);
250 Q_INVOKABLE
void moveCursorSelection(
int pos, QQuickTextEdit::SelectionMode mode);
252 QQuickTextSelection *cursorSelection()
const;
254 QRectF boundingRect()
const override;
255 QRectF clipRect()
const override;
257 bool isInputMethodComposing()
const;
259 RenderType renderType()
const;
260 void setRenderType(RenderType renderType);
262 Q_INVOKABLE QString getText(
int start,
int end)
const;
263 Q_INVOKABLE QString getFormattedText(
int start,
int end)
const;
265 QQuickTextDocument *textDocument();
267 QString hoveredLink()
const;
268 QString hoveredToolTip()
const;
270 Q_REVISION(2, 3) Q_INVOKABLE QString linkAt(qreal x, qreal y)
const;
272 qreal padding()
const;
273 void setPadding(qreal padding);
276 qreal topPadding()
const;
277 void setTopPadding(qreal padding);
278 void resetTopPadding();
280 qreal leftPadding()
const;
281 void setLeftPadding(qreal padding);
282 void resetLeftPadding();
284 qreal rightPadding()
const;
285 void setRightPadding(qreal padding);
286 void resetRightPadding();
288 qreal bottomPadding()
const;
289 void setBottomPadding(qreal padding);
290 void resetBottomPadding();
292 int tabStopDistance()
const;
293 void setTabStopDistance(qreal distance);
295 void invalidate() override;
299 Q_REVISION(2, 7)
void preeditTextChanged();
300 void contentSizeChanged();
301 void cursorPositionChanged();
302 void cursorRectangleChanged();
303 void selectionStartChanged();
304 void selectionEndChanged();
305 void selectedTextChanged();
306 void colorChanged(
const QColor &color);
307 void selectionColorChanged(
const QColor &color);
308 void selectedTextColorChanged(
const QColor &color);
309 void fontChanged(
const QFont &font);
310 void horizontalAlignmentChanged(QQuickTextEdit::HAlignment alignment);
311 void verticalAlignmentChanged(QQuickTextEdit::VAlignment alignment);
312 void wrapModeChanged();
313 void lineCountChanged();
314 void textFormatChanged(QQuickTextEdit::TextFormat textFormat);
315 void readOnlyChanged(
bool isReadOnly);
316 void cursorVisibleChanged(
bool isCursorVisible);
317 void cursorDelegateChanged();
318 void overwriteModeChanged(
bool overwriteMode);
319 void activeFocusOnPressChanged(
bool activeFocusOnPressed);
320 void persistentSelectionChanged(
bool isPersistentSelection);
321 void textMarginChanged(qreal textMargin);
322 Q_REVISION(2, 1)
void selectByKeyboardChanged(
bool selectByKeyboard);
323 void selectByMouseChanged(
bool selectByMouse);
324 void mouseSelectionModeChanged(QQuickTextEdit::SelectionMode mode);
325 void linkActivated(
const QString &link);
326 Q_REVISION(2, 2)
void linkHovered(
const QString &link);
327 Q_REVISION(6, 13)
void hoveredToolTipChanged();
328 void canPasteChanged();
329 void canUndoChanged();
330 void canRedoChanged();
331 void inputMethodComposingChanged();
332 void effectiveHorizontalAlignmentChanged();
333 void baseUrlChanged();
334 void inputMethodHintsChanged();
335 void renderTypeChanged();
336 Q_REVISION(2, 6)
void editingFinished();
337 Q_REVISION(2, 6)
void paddingChanged();
338 Q_REVISION(2, 6)
void topPaddingChanged();
339 Q_REVISION(2, 6)
void leftPaddingChanged();
340 Q_REVISION(2, 6)
void rightPaddingChanged();
341 Q_REVISION(2, 6)
void bottomPaddingChanged();
342 Q_REVISION(2, 10)
void tabStopDistanceChanged(qreal distance);
343 Q_REVISION(6, 9)
void textEdited();
348 void select(
int start,
int end);
350 bool isRightToLeft(
int start,
int end);
351#if QT_CONFIG(clipboard)
358 void insert(
int position,
const QString &text);
359 void remove(
int start,
int end);
360 Q_REVISION(2, 2)
void append(
const QString &text);
361 Q_REVISION(2, 7)
void clear();
365 void q_textChanged();
366 void q_contentsChange(
int,
int,
int);
367 void updateSelection();
368 void moveCursorDelegate();
370 void q_canPasteChanged();
371 void updateWholeDocument();
372 void invalidateBlock(
const QTextBlock &block);
374 void q_linkHovered(
const QString &link);
375 void q_markerHovered(
bool hovered);
376 void q_updateAlignment();
378 void triggerPreprocess();
379 Q_REVISION(6, 7) QVariant loadResource(
int type,
const QUrl &source);
380 void resourceRequestFinished();
383 void markDirtyNodesForRange(
int start,
int end,
int charDelta);
384 void updateTotalLines();
385 void invalidateFontCaches();
386 QTextDocument* document()
const;
387 void setDocument(QTextDocument *doc);
390 QQuickTextEdit(QQuickTextEditPrivate &dd, QQuickItem *parent =
nullptr);
391#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
392 void setOldSelectionDefault();
395 void geometryChange(
const QRectF &newGeometry,
const QRectF &oldGeometry) override;
396 void itemChange(ItemChange change,
const ItemChangeData &value) override;
398 bool event(QEvent *) override;
399 void keyPressEvent(QKeyEvent *) override;
400 void keyReleaseEvent(QKeyEvent *) override;
401 void focusInEvent(QFocusEvent *event) override;
402 void focusOutEvent(QFocusEvent *event) override;
404 void hoverEnterEvent(QHoverEvent *event) override;
405 void hoverMoveEvent(QHoverEvent *event) override;
406 void hoverLeaveEvent(QHoverEvent *event) override;
409 void mousePressEvent(QMouseEvent *event) override;
410 void mouseReleaseEvent(QMouseEvent *event) override;
411 void mouseDoubleClickEvent(QMouseEvent *event) override;
412 void mouseMoveEvent(QMouseEvent *event) override;
413#if QT_VERSION >= QT_VERSION_CHECK(7
, 0
, 0
)
414 bool contextMenuEvent(QContextMenuEvent *event) override;
417 void inputMethodEvent(QInputMethodEvent *e) override;
419 QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
420 void updatePolish() override;
422 friend class QQuickTextUtil;
423 friend class QQuickTextDocumentPrivate;
426 Q_DISABLE_COPY(QQuickTextEdit)
427 Q_DECLARE_PRIVATE(QQuickTextEdit)