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
qtextcursor.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 QTEXTCURSOR_H
5#define QTEXTCURSOR_H
6
7#include <QtGui/qtguiglobal.h>
8#include <QtCore/qstring.h>
9#include <QtCore/qshareddata.h>
10#include <QtGui/qtextdocument.h>
11#include <QtGui/qtextformat.h>
12
14
17class QTextCharFormat;
19class QTextListFormat;
24class QTextList;
25class QTextTable;
26class QTextFrame;
27class QTextBlock;
28
29class Q_GUI_EXPORT QTextCursor
30{
31public:
33 explicit QTextCursor(QTextDocument *document);
36 explicit QTextCursor(QTextFrame *frame);
37 explicit QTextCursor(const QTextBlock &block);
39 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QTextCursor)
40 QTextCursor &operator=(const QTextCursor &other);
42
43 void swap(QTextCursor &other) noexcept { d.swap(other.d); }
44
45 bool isNull() const;
46
47 enum MoveMode {
49 KeepAnchor
50 };
51
52 void setPosition(int pos, MoveMode mode = MoveAnchor);
53 int position() const;
54 int positionInBlock() const;
55
56 int anchor() const;
57
58 void insertText(const QString &text);
59 void insertText(const QString &text, const QTextCharFormat &format);
60
91
92 bool movePosition(MoveOperation op, MoveMode = MoveAnchor, int n = 1);
93
94 bool visualNavigation() const;
95 void setVisualNavigation(bool b);
96
97 void setVerticalMovementX(int x);
98 int verticalMovementX() const;
99
100 void setKeepPositionOnInsert(bool b);
101 bool keepPositionOnInsert() const;
102
103 void deleteChar();
104 void deletePreviousChar();
105
112 void select(SelectionType selection);
113
114 bool hasSelection() const;
115 bool hasComplexSelection() const;
116 void removeSelectedText();
117 void clearSelection();
118 int selectionStart() const;
119 int selectionEnd() const;
120
121 QString selectedText() const;
123 void selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const;
124
125 QTextBlock block() const;
126
127 QTextCharFormat charFormat() const;
128 void setCharFormat(const QTextCharFormat &format);
129 void mergeCharFormat(const QTextCharFormat &modifier);
130
131 QTextBlockFormat blockFormat() const;
132 void setBlockFormat(const QTextBlockFormat &format);
133 void mergeBlockFormat(const QTextBlockFormat &modifier);
134
135 QTextCharFormat blockCharFormat() const;
136 void setBlockCharFormat(const QTextCharFormat &format);
137 void mergeBlockCharFormat(const QTextCharFormat &modifier);
138
139 bool atBlockStart() const;
140 bool atBlockEnd() const;
141 bool atStart() const;
142 bool atEnd() const;
143
144 void insertBlock();
145 void insertBlock(const QTextBlockFormat &format);
146 void insertBlock(const QTextBlockFormat &format, const QTextCharFormat &charFormat);
147
148 QTextList *insertList(const QTextListFormat &format);
149 QTextList *insertList(QTextListFormat::Style style);
150
151 QTextList *createList(const QTextListFormat &format);
152 QTextList *createList(QTextListFormat::Style style);
153 QTextList *currentList() const;
154
155 QTextTable *insertTable(int rows, int cols, const QTextTableFormat &format);
156 QTextTable *insertTable(int rows, int cols);
157 QTextTable *currentTable() const;
158
159 QTextFrame *insertFrame(const QTextFrameFormat &format);
160 QTextFrame *currentFrame() const;
161
162 void insertFragment(const QTextDocumentFragment &fragment);
163
164#ifndef QT_NO_TEXTHTMLPARSER
165 void insertHtml(const QString &html);
166#endif // QT_NO_TEXTHTMLPARSER
167#if QT_CONFIG(textmarkdownreader)
168 void insertMarkdown(const QString &markdown,
169 QTextDocument::MarkdownFeatures features = QTextDocument::MarkdownDialectGitHub);
170#endif // textmarkdownreader
171
173 void insertImage(const QTextImageFormat &format);
174 void insertImage(const QString &name);
175 void insertImage(const QImage &image, const QString &name = QString());
176
177 void beginEditBlock();
178 void joinPreviousEditBlock();
179 void endEditBlock();
180
181 bool operator!=(const QTextCursor &rhs) const;
182 bool operator<(const QTextCursor &rhs) const;
183 bool operator<=(const QTextCursor &rhs) const;
184 bool operator==(const QTextCursor &rhs) const;
185 bool operator>=(const QTextCursor &rhs) const;
186 bool operator>(const QTextCursor &rhs) const;
187
188 bool isCopyOf(const QTextCursor &other) const;
189
190 int blockNumber() const;
191 int columnNumber() const;
192
193 QTextDocument *document() const;
194
195private:
196 QSharedDataPointer<QTextCursorPrivate> d;
197 friend class QTextCursorPrivate;
200 friend class QTextCopyHelper;
202};
203
204Q_DECLARE_SHARED(QTextCursor)
205
207
208#endif // QTEXTCURSOR_H
\inmodule QtGui
Definition qimage.h:37
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\reentrant
\reentrant \inmodule QtGui
Definition qtextcursor.h:30
SelectionType
This enum describes the types of selection that can be applied with the select() function.
MoveMode
\value MoveAnchor Moves the anchor to the same position as the cursor itself.
Definition qtextcursor.h:47
void swap(QTextCursor &other) noexcept
Definition qtextcursor.h:43
MoveOperation
\value NoMove Keep the cursor where it is
Definition qtextcursor.h:61
\reentrant \inmodule QtGui
Position
This enum describes how a frame is located relative to the surrounding text.
\reentrant
Definition qtextobject.h:81
Style
This enum describes the symbols used to decorate list items:
\reentrant
Definition qtextlist.h:18
\reentrant
Definition qtexttable.h:63
QString text
QCursor cursor
uint alignment
Combined button and popup list for selecting options.
Definition image.cpp:4
constexpr bool operator!=(const timespec &t1, const timespec &t2)
static bool hasSelection()
n void setPosition(void) \n\
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLenum mode
GLuint name
GLfloat n
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat p
[1]
bool operator>(const QPoint &a, const QPoint &b)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
static bool operator<(const QSettingsIniKey &k1, const QSettingsIniKey &k2)
bool operator<=(const QUuid &lhs, const QUuid &rhs) noexcept
Definition quuid.h:294
bool operator>=(const QUuid &lhs, const QUuid &rhs) noexcept
Definition quuid.h:296
QSharedPointer< T > other(t)
[5]
QItemSelection * selection
[0]
selection select(topLeft, bottomRight)
QFrame frame
[0]