Qt 4.8
Public Types | Public Functions | Properties | Friends | List of all members
QTextCursor Class Reference

The QTextCursor class offers an API to access and modify QTextDocuments. More...

#include <qtextcursor.h>

Public Types

enum  MoveMode { MoveAnchor, KeepAnchor }
 If the anchor() is kept where it is and the position() is moved, the text in between will be selected. More...
 
enum  MoveOperation {
  NoMove, Start, Up, StartOfLine,
  StartOfBlock, StartOfWord, PreviousBlock, PreviousCharacter,
  PreviousWord, Left, WordLeft, End,
  Down, EndOfLine, EndOfWord, EndOfBlock,
  NextBlock, NextCharacter, NextWord, Right,
  WordRight, NextCell, PreviousCell, NextRow,
  PreviousRow
}
 
enum  SelectionType { WordUnderCursor, LineUnderCursor, BlockUnderCursor, Document }
 This enum describes the types of selection that can be applied with the select() function. More...
 

Public Functions

int anchor () const
 Returns the anchor position; this is the same as position() unless there is a selection in which case position() marks one end of the selection and anchor() marks the other end. More...
 
bool atBlockEnd () const
 Returns true if the cursor is at the end of a block; otherwise returns false. More...
 
bool atBlockStart () const
 Returns true if the cursor is at the start of a block; otherwise returns false. More...
 
bool atEnd () const
 Returns true if the cursor is at the end of the document; otherwise returns false. More...
 
bool atStart () const
 Returns true if the cursor is at the start of the document; otherwise returns false. More...
 
void beginEditBlock ()
 Indicates the start of a block of editing operations on the document that should appear as a single operation from an undo/redo point of view. More...
 
QTextBlock block () const
 Returns the block that contains the cursor. More...
 
QTextCharFormat blockCharFormat () const
 Returns the block character format of the block the cursor is in. More...
 
QTextBlockFormat blockFormat () const
 Returns the block format of the block the cursor is in. More...
 
int blockNumber () const
 Returns the number of the block the cursor is in, or 0 if the cursor is invalid. More...
 
QTextCharFormat charFormat () const
 Returns the format of the character immediately before the cursor position(). More...
 
void clearSelection ()
 Clears the current selection by setting the anchor to the cursor position. More...
 
int columnNumber () const
 Returns the position of the cursor within its containing line. More...
 
QTextListcreateList (const QTextListFormat &format)
 Creates and returns a new list with the given format, and makes the current paragraph the cursor is in the first list item. More...
 
QTextListcreateList (QTextListFormat::Style style)
 Creates and returns a new list with the given style, making the cursor's current paragraph the first list item. More...
 
QTextFramecurrentFrame () const
 Returns a pointer to the current frame. More...
 
QTextListcurrentList () const
 Returns the current list if the cursor position() is inside a block that is part of a list; otherwise returns 0. More...
 
QTextTablecurrentTable () const
 Returns a pointer to the current table if the cursor position() is inside a block that is part of a table; otherwise returns 0. More...
 
void deleteChar ()
 If there is no selected text, deletes the character at the current cursor position; otherwise deletes the selected text. More...
 
void deletePreviousChar ()
 If there is no selected text, deletes the character before the current cursor position; otherwise deletes the selected text. More...
 
QTextDocumentdocument () const
 Returns the document this cursor is associated with. More...
 
void endEditBlock ()
 Indicates the end of a block of editing operations on the document that should appear as a single operation from an undo/redo point of view. More...
 
bool hasComplexSelection () const
 Returns true if the cursor contains a selection that is not simply a range from selectionStart() to selectionEnd(); otherwise returns false. More...
 
bool hasSelection () const
 Returns true if the cursor contains a selection; otherwise returns false. More...
 
void insertBlock ()
 Inserts a new empty block at the cursor position() with the current blockFormat() and charFormat(). More...
 
void insertBlock (const QTextBlockFormat &format)
 Inserts a new empty block at the cursor position() with block format format and the current charFormat() as block char format. More...
 
void insertBlock (const QTextBlockFormat &format, const QTextCharFormat &charFormat)
 Inserts a new empty block at the cursor position() with block format format and charFormat as block char format. More...
 
void insertFragment (const QTextDocumentFragment &fragment)
 Inserts the text fragment at the current position(). More...
 
QTextFrameinsertFrame (const QTextFrameFormat &format)
 Inserts a frame with the given format at the current cursor position(), moves the cursor position() inside the frame, and returns the frame. More...
 
void insertHtml (const QString &html)
 Inserts the text html at the current position(). More...
 
void insertImage (const QTextImageFormat &format, QTextFrameFormat::Position alignment)
 Inserts the image defined by the given format at the cursor's current position with the specified alignment. More...
 
void insertImage (const QTextImageFormat &format)
 Inserts the image defined by format at the current position(). More...
 
void insertImage (const QString &name)
 Convenience method for inserting the image with the given name at the current position(). More...
 
void insertImage (const QImage &image, const QString &name=QString())
 Convenience function for inserting the given image with an optional name at the current position(). More...
 
QTextListinsertList (const QTextListFormat &format)
 Inserts a new block at the current position and makes it the first list item of a newly created list with the given format. More...
 
QTextListinsertList (QTextListFormat::Style style)
 Inserts a new block at the current position and makes it the first list item of a newly created list with the given style. More...
 
QTextTableinsertTable (int rows, int cols, const QTextTableFormat &format)
 Creates a new table with the given number of rows and columns in the specified format, inserts it at the current cursor position() in the document, and returns the table object. More...
 
QTextTableinsertTable (int rows, int cols)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Creates a new table with the given number of rows and columns, inserts it at the current cursor position() in the document, and returns the table object. More...
 
void insertText (const QString &text)
 Inserts text at the current position, using the current character format. More...
 
void insertText (const QString &text, const QTextCharFormat &format)
 Inserts text at the current position with the given format. More...
 
bool isCopyOf (const QTextCursor &other) const
 Returns true if this cursor and other are copies of each other, i.e. More...
 
bool isNull () const
 Returns true if the cursor is null; otherwise returns false. More...
 
void joinPreviousEditBlock ()
 Like beginEditBlock() indicates the start of a block of editing operations that should appear as a single operation for undo/redo. More...
 
bool keepPositionOnInsert () const
 Returns whether the cursor should keep its current position when text gets inserted at the position of the cursor. More...
 
void mergeBlockCharFormat (const QTextCharFormat &modifier)
 Modifies the block char format of the current block (or all blocks that are contained in the selection) with the block format specified by modifier. More...
 
void mergeBlockFormat (const QTextBlockFormat &modifier)
 Modifies the block format of the current block (or all blocks that are contained in the selection) with the block format specified by modifier. More...
 
void mergeCharFormat (const QTextCharFormat &modifier)
 Merges the cursor's current character format with the properties described by format modifier. More...
 
bool movePosition (MoveOperation op, MoveMode=MoveAnchor, int n=1)
 Moves the cursor by performing the given operation n times, using the specified mode, and returns true if all operations were completed successfully; otherwise returns false. More...
 
bool operator!= (const QTextCursor &rhs) const
 Returns true if the other cursor is at a different position in the document as this cursor; otherwise returns false. More...
 
bool operator< (const QTextCursor &rhs) const
 Returns true if the other cursor is positioned later in the document than this cursor; otherwise returns false. More...
 
bool operator<= (const QTextCursor &rhs) const
 Returns true if the other cursor is positioned later or at the same position in the document as this cursor; otherwise returns false. More...
 
QTextCursoroperator= (const QTextCursor &other)
 Makes a copy of cursor and assigns it to this QTextCursor. More...
 
bool operator== (const QTextCursor &rhs) const
 Returns true if the other cursor is at the same position in the document as this cursor; otherwise returns false. More...
 
bool operator> (const QTextCursor &rhs) const
 Returns true if the other cursor is positioned earlier in the document than this cursor; otherwise returns false. More...
 
bool operator>= (const QTextCursor &rhs) const
 Returns true if the other cursor is positioned earlier or at the same position in the document as this cursor; otherwise returns false. More...
 
int position () const
 Returns the absolute position of the cursor within the document. More...
 
int positionInBlock () const
 Returns the relative position of the cursor within the block. More...
 
 QTextCursor ()
 Constructs a null cursor. More...
 
 QTextCursor (QTextDocument *document)
 Constructs a cursor pointing to the beginning of the document. More...
 
 QTextCursor (QTextDocumentPrivate *p, int pos)
 
 QTextCursor (QTextFrame *frame)
 Constructs a cursor pointing to the beginning of the frame. More...
 
 QTextCursor (const QTextBlock &block)
 Constructs a cursor pointing to the beginning of the block. More...
 
 QTextCursor (QTextCursorPrivate *d)
 
 QTextCursor (const QTextCursor &cursor)
 Constructs a new cursor that is a copy of cursor. More...
 
void removeSelectedText ()
 If there is a selection, its content is deleted; otherwise does nothing. More...
 
void select (SelectionType selection)
 Selects text in the document according to the given selection. More...
 
void selectedTableCells (int *firstRow, int *numRows, int *firstColumn, int *numColumns) const
 If the selection spans over table cells, firstRow is populated with the number of the first row in the selection, firstColumn with the number of the first column in the selection, and numRows and numColumns with the number of rows and columns in the selection. More...
 
QString selectedText () const
 Returns the current selection's text (which may be empty). More...
 
QTextDocumentFragment selection () const
 Returns the current selection (which may be empty) with all its formatting information. More...
 
int selectionEnd () const
 Returns the end of the selection or position() if the cursor doesn't have a selection. More...
 
int selectionStart () const
 Returns the start of the selection or position() if the cursor doesn't have a selection. More...
 
void setBlockCharFormat (const QTextCharFormat &format)
 Sets the block char format of the current block (or all blocks that are contained in the selection) to format. More...
 
void setBlockFormat (const QTextBlockFormat &format)
 Sets the block format of the current block (or all blocks that are contained in the selection) to format. More...
 
void setCharFormat (const QTextCharFormat &format)
 Sets the cursor's current character format to the given format. More...
 
void setKeepPositionOnInsert (bool b)
 Defines whether the cursor should keep its current position when text gets inserted at the current position of the cursor. More...
 
void setPosition (int pos, MoveMode mode=MoveAnchor)
 Moves the cursor to the absolute position in the document specified by pos using a MoveMode specified by m. More...
 
void setVerticalMovementX (int x)
 Sets the visual x position for vertical cursor movements to x. More...
 
void setVisualNavigation (bool b)
 Sets visual navigation to b. More...
 
int verticalMovementX () const
 Returns the visual x position for vertical cursor movements. More...
 
bool visualNavigation () const
 Returns true if the cursor does visual navigation; otherwise returns false. More...
 
 ~QTextCursor ()
 Destroys the QTextCursor. More...
 

Properties

QSharedDataPointer< QTextCursorPrivated
 

Friends

class QTextControlPrivate
 
class QTextCopyHelper
 
class QTextDocumentFragmentPrivate
 

Detailed Description

The QTextCursor class offers an API to access and modify QTextDocuments.

Note
This class or function is reentrant.

Text cursors are objects that are used to access and modify the contents and underlying structure of text documents via a programming interface that mimics the behavior of a cursor in a text editor. QTextCursor contains information about both the cursor's position within a QTextDocument and any selection that it has made.

QTextCursor is modeled on the way a text cursor behaves in a text editor, providing a programmatic means of performing standard actions through the user interface. A document can be thought of as a single string of characters. The cursor's current position() then is always either between two consecutive characters in the string, or else before the very first character or after the very last character in the string. Documents can also contain tables, lists, images, and other objects in addition to text but, from the developer's point of view, the document can be treated as one long string. Some portions of that string can be considered to lie within particular blocks (e.g. paragraphs), or within a table's cell, or a list's item, or other structural elements. When we refer to "current character" we mean the character immediately before the cursor position() in the document. Similarly, the "current block" is the block that contains the cursor position().

A QTextCursor also has an anchor() position. The text that is between the anchor() and the position() is the selection. If anchor() == position() there is no selection.

The cursor position can be changed programmatically using setPosition() and movePosition(); the latter can also be used to select text. For selections see selectionStart(), selectionEnd(), hasSelection(), clearSelection(), and removeSelectedText().

If the position() is at the start of a block atBlockStart() returns true; and if it is at the end of a block atBlockEnd() returns true. The format of the current character is returned by charFormat(), and the format of the current block is returned by blockFormat().

Formatting can be applied to the current text document using the setCharFormat(), mergeCharFormat(), setBlockFormat() and mergeBlockFormat() functions. The 'set' functions will replace the cursor's current character or block format, while the 'merge' functions add the given format properties to the cursor's current format. If the cursor has a selection the given format is applied to the current selection. Note that when only parts of a block is selected the block format is applied to the entire block. The text at the current character position can be turned into a list using createList().

Deletions can be achieved using deleteChar(), deletePreviousChar(), and removeSelectedText().

Text strings can be inserted into the document with the insertText() function, blocks (representing new paragraphs) can be inserted with insertBlock().

Existing fragments of text can be inserted with insertFragment() but, if you want to insert pieces of text in various formats, it is usually still easier to use insertText() and supply a character format.

Various types of higher-level structure can also be inserted into the document with the cursor:

Actions can be grouped (i.e. treated as a single action for undo/redo) using beginEditBlock() and endEditBlock().

Cursor movements are limited to valid cursor positions. In Latin writing this is between any two consecutive characters in the text, before the first character, or after the last character. In some other writing systems cursor movements are limited to "clusters" (e.g. a syllable in Devanagari, or a base letter plus diacritics). Functions such as movePosition() and deleteChar() limit cursor movement to these valid positions.

See also
Rich Text Processing

Definition at line 70 of file qtextcursor.h.

Enumerations

◆ MoveMode

If the anchor() is kept where it is and the position() is moved, the text in between will be selected.

  • MoveAnchor Moves the anchor to the same position as the cursor itself.
  • KeepAnchor Keeps the anchor where it is.
Enumerator
MoveAnchor 
KeepAnchor 

Definition at line 85 of file qtextcursor.h.

◆ MoveOperation

  • NoMove Keep the cursor where it is
  • Start Move to the start of the document.
  • StartOfLine Move to the start of the current line.
  • StartOfBlock Move to the start of the current block.
  • StartOfWord Move to the start of the current word.
  • PreviousBlock Move to the start of the previous block.
  • PreviousCharacter Move to the previous character.
  • PreviousWord Move to the beginning of the previous word.
  • Up Move up one line.
  • Left Move left one character.
  • WordLeft Move left one word.
  • End Move to the end of the document.
  • EndOfLine Move to the end of the current line.
  • EndOfWord Move to the end of the current word.
  • EndOfBlock Move to the end of the current block.
  • NextBlock Move to the beginning of the next block.
  • NextCharacter Move to the next character.
  • NextWord Move to the next word.
  • Down Move down one line.
  • Right Move right one character.
  • WordRight Move right one word.
  • NextCell Move to the beginning of the next table cell inside the current table. If the current cell is the last cell in the row, the cursor will move to the first cell in the next row.
  • PreviousCell Move to the beginning of the previous table cell inside the current table. If the current cell is the first cell in the row, the cursor will move to the last cell in the previous row.
  • NextRow Move to the first new cell of the next row in the current table.
  • PreviousRow Move to the last cell of the previous row in the current table.
See also
movePosition()
Enumerator
NoMove 
Start 
Up 
StartOfLine 
StartOfBlock 
StartOfWord 
PreviousBlock 
PreviousCharacter 
PreviousWord 
Left 
WordLeft 
End 
Down 
EndOfLine 
EndOfWord 
EndOfBlock 
NextBlock 
NextCharacter 
NextWord 
Right 
WordRight 
NextCell 
PreviousCell 
NextRow 
PreviousRow 

Definition at line 99 of file qtextcursor.h.

99  {
100  NoMove,
101 
102  Start,
103  Up,
104  StartOfLine,
105  StartOfBlock,
106  StartOfWord,
109  PreviousWord,
110  Left,
111  WordLeft,
112 
113  End,
114  Down,
115  EndOfLine,
116  EndOfWord,
117  EndOfBlock,
118  NextBlock,
120  NextWord,
121  Right,
122  WordRight,
123 
124  NextCell,
125  PreviousCell,
126  NextRow,
128  };

◆ SelectionType

This enum describes the types of selection that can be applied with the select() function.

  • Document Selects the entire document.
  • BlockUnderCursor Selects the block of text under the cursor.
  • LineUnderCursor Selects the line of text under the cursor.
  • WordUnderCursor Selects the word under the cursor. If the cursor is not positioned within a string of selectable characters, no text is selected.
Enumerator
WordUnderCursor 
LineUnderCursor 
BlockUnderCursor 
Document 

Definition at line 144 of file qtextcursor.h.

Constructors and Destructors

◆ QTextCursor() [1/7]

QTextCursor::QTextCursor ( )

Constructs a null cursor.

Definition at line 1069 of file qtextcursor.cpp.

1070  : d(0)
1071 {
1072 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230

◆ QTextCursor() [2/7]

QTextCursor::QTextCursor ( QTextDocument document)
explicit

Constructs a cursor pointing to the beginning of the document.

Definition at line 1077 of file qtextcursor.cpp.

1078  : d(new QTextCursorPrivate(document->docHandle()))
1079 {
1080 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * docHandle() const
So that not all classes have to be friends of each other.

◆ QTextCursor() [3/7]

QTextCursor::QTextCursor ( QTextDocumentPrivate p,
int  pos 
)
Warning
This function is not part of the public interface.

Definition at line 1105 of file qtextcursor.cpp.

1106  : d(new QTextCursorPrivate(p))
1107 {
1108  d->adjusted_anchor = d->anchor = d->position = pos;
1109 
1110  d->setX();
1111 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230

◆ QTextCursor() [4/7]

QTextCursor::QTextCursor ( QTextFrame frame)
explicit

Constructs a cursor pointing to the beginning of the frame.

Definition at line 1085 of file qtextcursor.cpp.

1086  : d(new QTextCursorPrivate(frame->document()->docHandle()))
1087 {
1088  d->adjusted_anchor = d->anchor = d->position = frame->firstPosition();
1089 }
QTextDocument * document() const
Returns the document this object belongs to.
int firstPosition() const
Returns the first document position inside the frame.
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * docHandle() const
So that not all classes have to be friends of each other.

◆ QTextCursor() [5/7]

QTextCursor::QTextCursor ( const QTextBlock block)
explicit

Constructs a cursor pointing to the beginning of the block.

Definition at line 1095 of file qtextcursor.cpp.

1096  : d(new QTextCursorPrivate(block.docHandle()))
1097 {
1098  d->adjusted_anchor = d->anchor = d->position = block.position();
1099 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
int position() const
Returns the index of the block&#39;s first character within the document.
QTextDocumentPrivate * docHandle() const
Definition: qtextobject.h:283

◆ QTextCursor() [6/7]

QTextCursor::QTextCursor ( QTextCursorPrivate d)
explicit
Warning
This function is not part of the public interface.

Definition at line 1116 of file qtextcursor.cpp.

1117 {
1118  Q_ASSERT(d);
1119  this->d = d;
1120 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230

◆ QTextCursor() [7/7]

QTextCursor::QTextCursor ( const QTextCursor cursor)

Constructs a new cursor that is a copy of cursor.

Definition at line 1125 of file qtextcursor.cpp.

1126 {
1127  d = cursor.d;
1128 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230

◆ ~QTextCursor()

QTextCursor::~QTextCursor ( )

Destroys the QTextCursor.

Definition at line 1145 of file qtextcursor.cpp.

1146 {
1147 }

Functions

◆ anchor()

int QTextCursor::anchor ( ) const

Returns the anchor position; this is the same as position() unless there is a selection in which case position() marks one end of the selection and anchor() marks the other end.

Just like the cursor position, the anchor position is between characters.

See also
position() setPosition() movePosition() selectionStart() selectionEnd()

Definition at line 1230 of file qtextcursor.cpp.

Referenced by QTextBrowserPrivate::createHistoryEntry(), QTextControlPrivate::cursorMoveKeyEvent(), QDeclarativeTextEdit::moveCursorSelection(), QTextControlPrivate::repaintOldAndNewSelection(), QDeclarativeTextEdit::setCursorPosition(), QTextControl::setExtraSelections(), and setPosition().

1231 {
1232  if (!d || !d->priv)
1233  return -1;
1234  return d->anchor;
1235 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * priv

◆ atBlockEnd()

bool QTextCursor::atBlockEnd ( ) const

Returns true if the cursor is at the end of a block; otherwise returns false.

See also
atBlockStart(), atEnd()

Definition at line 2008 of file qtextcursor.cpp.

2009 {
2010  if (!d || !d->priv)
2011  return false;
2012 
2013  return d->position == d->block().position() + d->block().length() - 1;
2014 }
QTextBlock block() const
Definition: qtextcursor_p.h:93
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
int position() const
Returns the index of the block&#39;s first character within the document.
int length() const
Returns the length of the block in characters.
QTextDocumentPrivate * priv

◆ atBlockStart()

bool QTextCursor::atBlockStart ( ) const

Returns true if the cursor is at the start of a block; otherwise returns false.

See also
atBlockEnd(), atStart()

Definition at line 1994 of file qtextcursor.cpp.

Referenced by QTextEdit::keyPressEvent(), QPlainTextEdit::keyReleaseEvent(), and QTextEdit::keyReleaseEvent().

1995 {
1996  if (!d || !d->priv)
1997  return false;
1998 
1999  return d->position == d->block().position();
2000 }
QTextBlock block() const
Definition: qtextcursor_p.h:93
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
int position() const
Returns the index of the block&#39;s first character within the document.
QTextDocumentPrivate * priv

◆ atEnd()

bool QTextCursor::atEnd ( ) const

Returns true if the cursor is at the end of the document; otherwise returns false.

Since
4.6
See also
atStart(), atBlockEnd()

Definition at line 2041 of file qtextcursor.cpp.

2042 {
2043  if (!d || !d->priv)
2044  return false;
2045 
2046  return d->position == d->priv->length() - 1;
2047 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * priv

◆ atStart()

bool QTextCursor::atStart ( ) const

Returns true if the cursor is at the start of the document; otherwise returns false.

See also
atBlockStart(), atEnd()

Definition at line 2022 of file qtextcursor.cpp.

2023 {
2024  if (!d || !d->priv)
2025  return false;
2026 
2027  return d->position == 0;
2028 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * priv

◆ beginEditBlock()

void QTextCursor::beginEditBlock ( )

Indicates the start of a block of editing operations on the document that should appear as a single operation from an undo/redo point of view.

For example:

QTextCursor cursor(textDocument);
cursor.beginEditBlock();
cursor.insertText("Hello");
cursor.insertText("World");
cursor.endEditBlock();
textDocument->undo();

The call to undo() will cause both insertions to be undone, causing both "World" and "Hello" to be removed.

It is possible to nest calls to beginEditBlock and endEditBlock. The top-most pair will determine the scope of the undo/redo operation.

See also
endEditBlock()

Definition at line 2552 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::append(), QTextControlPrivate::createAutoBulletList(), QTextEditPrivate::createAutoBulletList(), QTextControlPrivate::dropEvent(), QTextHtmlImporter::import(), QSyntaxHighlighterPrivate::rehighlight(), QDeclarativeTextEdit::select(), QTextControlPrivate::setContent(), QSyntaxHighlighter::setDocument(), QDeclarativeTextEditPrivate::updateSelection(), and QDeclarativeJS::TextWriter::write_helper().

2553 {
2554  if (!d || !d->priv)
2555  return;
2556 
2557  if (d->priv->editBlock == 0) // we are the initial edit block, store current cursor position for undo
2559 
2560  d->priv->beginEditBlock();
2561 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * priv

◆ block()

QTextBlock QTextCursor::block ( ) const

Returns the block that contains the cursor.

Definition at line 1812 of file qtextcursor.cpp.

Referenced by charFormat(), QAccessibleTextEdit::childAt(), columnNumber(), currentTextLine(), QTextControlPrivate::cursorMoveKeyEvent(), QScriptDebuggerCodeView::event(), QTextControlPrivate::extendWordwiseSelection(), QScriptEdit::extraAreaMouseEvent(), QTextControlPrivate::indent(), QPlainTextEdit::keyReleaseEvent(), QTextEdit::keyReleaseEvent(), QTextTable::mergeCells(), QDeclarativeTextEdit::positionAt(), QTextHtmlImporter::processBlockNode(), select(), and QTextEdit::setText().

1813 {
1814  if (!d || !d->priv)
1815  return QTextBlock();
1816  return d->block();
1817 }
QTextBlock block() const
Definition: qtextcursor_p.h:93
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
QTextDocumentPrivate * priv

◆ blockCharFormat()

QTextCharFormat QTextCursor::blockCharFormat ( ) const

Returns the block character format of the block the cursor is in.

The block char format is the format used when inserting text at the beginning of an empty block.

See also
setBlockCharFormat()

Definition at line 1869 of file qtextcursor.cpp.

Referenced by QTextDocumentPrivate::ensureMaximumBlockCount(), and QTextHtmlImporter::processBlockNode().

1870 {
1871  if (!d || !d->priv)
1872  return QTextCharFormat();
1873 
1874  return d->block().charFormat();
1875 }
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
QTextBlock block() const
Definition: qtextcursor_p.h:93
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextCharFormat charFormat() const
Returns the QTextCharFormat that describes the block&#39;s character format.
QTextDocumentPrivate * priv

◆ blockFormat()

QTextBlockFormat QTextCursor::blockFormat ( ) const

Returns the block format of the block the cursor is in.

See also
setBlockFormat() charFormat()

Definition at line 1824 of file qtextcursor.cpp.

Referenced by QTextHtmlImporter::appendNodeText(), QAccessibleTextWidget::attributes(), QTextControlPrivate::createAutoBulletList(), QTextEditPrivate::createAutoBulletList(), currentList(), QTextHtmlImporter::import(), QTextControlPrivate::indent(), insertBlock(), insertText(), QPlainTextEdit::keyReleaseEvent(), QTextEdit::keyReleaseEvent(), QTextControlPrivate::outdent(), and QTextHtmlImporter::processBlockNode().

1825 {
1826  if (!d || !d->priv)
1827  return QTextBlockFormat();
1828 
1829  return d->block().blockFormat();
1830 }
QTextBlock block() const
Definition: qtextcursor_p.h:93
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument...
Definition: qtextformat.h:545
QTextDocumentPrivate * priv
QTextBlockFormat blockFormat() const
Returns the QTextBlockFormat that describes block-specific properties.

◆ blockNumber()

int QTextCursor::blockNumber ( ) const

Returns the number of the block the cursor is in, or 0 if the cursor is invalid.

Since
4.2

Note that this function only makes sense in documents without complex objects such as tables or frames.

Definition at line 2623 of file qtextcursor.cpp.

Referenced by QScriptEdit::currentLineNumber(), QScriptDebuggerCodeView::event(), and QScriptEdit::extraAreaMouseEvent().

2624 {
2625  if (!d || !d->priv)
2626  return 0;
2627 
2628  return d->block().blockNumber();
2629 }
QTextBlock block() const
Definition: qtextcursor_p.h:93
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * priv
int blockNumber() const
Returns the number of this block, or -1 if the block is invalid.

◆ charFormat()

QTextCharFormat QTextCursor::charFormat ( ) const

Returns the format of the character immediately before the cursor position().

If the cursor is positioned at the beginning of a text block that is not empty then the format of the character immediately after the cursor is returned.

See also
insertText(), blockFormat()

Definition at line 1914 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::activateLinkUnderCursor(), QTextControlPrivate::anchorForCursor(), QTextHtmlImporter::appendNodeText(), QAccessibleTextWidget::attributes(), QTextDocumentLayoutPrivate::drawListItem(), QTextDocumentFragmentPrivate::insert(), insertBlock(), insertText(), QTextBrowser::keyPressEvent(), QPlainTextEdit::keyPressEvent(), QTextEdit::keyPressEvent(), mergeCharFormat(), QTextControlPrivate::setContent(), and QTextControlPrivate::updateCurrentCharFormat().

1915 {
1916  if (!d || !d->priv)
1917  return QTextCharFormat();
1918 
1919  int idx = d->currentCharFormat;
1920  if (idx == -1) {
1921  QTextBlock block = d->block();
1922 
1923  int pos;
1924  if (d->position == block.position()
1925  && block.length() > 1)
1926  pos = d->position;
1927  else
1928  pos = d->position - 1;
1929 
1930  if (pos == -1) {
1932  } else {
1933  Q_ASSERT(pos >= 0 && pos < d->priv->length());
1934 
1936  Q_ASSERT(!it.atEnd());
1937  idx = it.value()->format;
1938  }
1939  }
1940 
1943 
1944  Q_ASSERT(cfmt.isValid());
1945  return cfmt;
1946 }
QTextCharFormat charFormat(int index) const
Definition: qtextformat_p.h:85
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
#define it(className, varName)
QTextBlock block() const
Definition: qtextcursor_p.h:93
bool isValid() const
Returns true if this character format is valid; otherwise returns false.
Definition: qtextformat.h:397
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int blockCharFormatIndex(int node) const
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
FragmentMap::ConstIterator FragmentIterator
int position() const
Returns the index of the block&#39;s first character within the document.
FragmentIterator find(int pos) const
QTextFormatCollection * formatCollection()
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
int length() const
Returns the length of the block in characters.
const BlockMap & blockMap() const
QTextBlock block() const
Returns the block that contains the cursor.
static const QMetaObjectPrivate * priv(const uint *data)
if(void) toggleToolbarShown
QTextDocumentPrivate * priv
void clearProperty(int propertyId)
Clears the value of the property given by propertyId.
int firstNode() const

◆ clearSelection()

void QTextCursor::clearSelection ( )

Clears the current selection by setting the anchor to the cursor position.

Note that it does not delete the text of the selection.

See also
removeSelectedText() hasSelection()

Definition at line 1677 of file qtextcursor.cpp.

Referenced by QDeclarativeTextEdit::deselect(), QLabel::focusOutEvent(), QAccessibleTextWidget::removeSelection(), select(), QTextBrowserPrivate::setSource(), and QScriptEdit::updateExtraSelections().

1678 {
1679  if (!d)
1680  return;
1682  d->currentCharFormat = -1;
1683 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230

◆ columnNumber()

int QTextCursor::columnNumber ( ) const

Returns the position of the cursor within its containing line.

Since
4.2

Note that this is the column number relative to a wrapped line, not relative to the block (i.e. the paragraph).

You probably want to call positionInBlock() instead.

See also
positionInBlock()

Definition at line 2646 of file qtextcursor.cpp.

2647 {
2648  if (!d || !d->priv)
2649  return 0;
2650 
2651  QTextBlock block = d->block();
2652  if (!block.isValid())
2653  return 0;
2654 
2655  const QTextLayout *layout = d->blockLayout(block);
2656 
2657  const int relativePos = d->position - block.position();
2658 
2659  if (layout->lineCount() == 0)
2660  return relativePos;
2661 
2662  QTextLine line = layout->lineForTextPosition(relativePos);
2663  if (!line.isValid())
2664  return 0;
2665  return relativePos - line.textStart();
2666 }
QTextBlock block() const
Definition: qtextcursor_p.h:93
The QTextLine class represents a line of text inside a QTextLayout.
Definition: qtextlayout.h:197
QTextLayout * blockLayout(QTextBlock &block) const
bool isValid() const
Returns true if this text line is valid; otherwise returns false.
Definition: qtextlayout.h:201
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextLine lineForTextPosition(int pos) const
Returns the line that contains the cursor position specified by pos.
int position() const
Returns the index of the block&#39;s first character within the document.
const char * layout
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
QTextBlock block() const
Returns the block that contains the cursor.
The QTextLayout class is used to lay out and render text.
Definition: qtextlayout.h:105
QTextDocumentPrivate * priv
bool isValid() const
Returns true if this text block is valid; otherwise returns false.
Definition: qtextobject.h:208
int textStart() const
Returns the start of the line from the beginning of the string passed to the QTextLayout.
int lineCount() const
Returns the number of lines in this text layout.

◆ createList() [1/2]

QTextList * QTextCursor::createList ( const QTextListFormat format)

Creates and returns a new list with the given format, and makes the current paragraph the cursor is in the first list item.

See also
insertList() currentList()

Definition at line 2142 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::createAutoBulletList(), QTextEditPrivate::createAutoBulletList(), createList(), QTextControlPrivate::indent(), insertList(), and QTextHtmlImporter::processBlockNode().

2143 {
2144  if (!d || !d->priv)
2145  return 0;
2146 
2147  QTextList *list = static_cast<QTextList *>(d->priv->createObject(format));
2148  QTextBlockFormat modifier;
2149  modifier.setObjectIndex(list->objectIndex());
2150  mergeBlockFormat(modifier);
2151  return list;
2152 }
void mergeBlockFormat(const QTextBlockFormat &modifier)
Modifies the block format of the current block (or all blocks that are contained in the selection) wi...
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
int objectIndex() const
Returns the object index of this object.
QTextObject * createObject(const QTextFormat &newFormat, int objectIndex=-1)
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument...
Definition: qtextformat.h:545
QTextDocumentPrivate * priv
The QTextList class provides a decorated list of items in a QTextDocument.
Definition: qtextlist.h:57
void setObjectIndex(int object)
Sets the format object&#39;s object index.

◆ createList() [2/2]

QTextList * QTextCursor::createList ( QTextListFormat::Style  style)

Creates and returns a new list with the given style, making the cursor's current paragraph the first list item.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

The style to be used is defined by the QTextListFormat::Style enum.

See also
insertList() currentList()

Definition at line 2167 of file qtextcursor.cpp.

2168 {
2169  QTextListFormat fmt;
2170  fmt.setStyle(style);
2171  return createList(fmt);
2172 }
The QTextListFormat class provides formatting information for lists in a QTextDocument.
Definition: qtextformat.h:642
QTextList * createList(const QTextListFormat &format)
Creates and returns a new list with the given format, and makes the current paragraph the cursor is i...
void setStyle(Style style)
Sets the list format&#39;s style.
Definition: qtextformat.h:682

◆ currentFrame()

QTextFrame * QTextCursor::currentFrame ( ) const

Returns a pointer to the current frame.

Returns 0 if the cursor is invalid.

See also
insertFrame()

Definition at line 2277 of file qtextcursor.cpp.

Referenced by boundingRectOfFloatsInSelection(), QTextControlPrivate::repaintOldAndNewSelection(), QTextHtmlImporter::scanTable(), and QTextControl::selectionRect().

2278 {
2279  if(!d || !d->priv)
2280  return 0;
2281 
2282  return d->priv->frameAt(d->position);
2283 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextFrame * frameAt(int pos) const
QTextDocumentPrivate * priv

◆ currentList()

QTextList * QTextCursor::currentList ( ) const

Returns the current list if the cursor position() is inside a block that is part of a list; otherwise returns 0.

See also
insertList() createList()

Definition at line 2180 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::indent(), QTextEdit::keyPressEvent(), QPlainTextEdit::keyReleaseEvent(), QTextEdit::keyReleaseEvent(), and QTextControlPrivate::outdent().

2181 {
2182  if (!d || !d->priv)
2183  return 0;
2184 
2186  QTextObject *o = d->priv->objectForFormat(b);
2187  return qobject_cast<QTextList *>(o);
2188 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
QTextBlockFormat blockFormat() const
Returns the block format of the block the cursor is in.
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextObject * objectForFormat(int formatIndex) const
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument...
Definition: qtextformat.h:545
QTextDocumentPrivate * priv
The QTextList class provides a decorated list of items in a QTextDocument.
Definition: qtextlist.h:57
The QTextObject class is a base class for different kinds of objects that can group parts of a QTextD...
Definition: qtextobject.h:64

◆ currentTable()

QTextTable * QTextCursor::currentTable ( ) const

Returns a pointer to the current table if the cursor position() is inside a block that is part of a table; otherwise returns 0.

See also
insertTable()

Definition at line 2240 of file qtextcursor.cpp.

Referenced by QTextCopyHelper::copy(), QTextDocumentLayoutPrivate::drawFrame(), QTextControlPrivate::gotoNextTableCell(), QTextControlPrivate::gotoPreviousTableCell(), and QTextControl::selectionRect().

2241 {
2242  if(!d || !d->priv)
2243  return 0;
2244 
2245  QTextFrame *frame = d->priv->frameAt(d->position);
2246  while (frame) {
2247  QTextTable *table = qobject_cast<QTextTable *>(frame);
2248  if (table)
2249  return table;
2250  frame = frame->parentFrame();
2251  }
2252  return 0;
2253 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
The QTextFrame class represents a frame in a QTextDocument.
Definition: qtextobject.h:122
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextFrame * frameAt(int pos) const
QTextFrame * parentFrame() const
Returns the frame&#39;s parent frame.
The QTextTable class represents a table in a QTextDocument.
Definition: qtexttable.h:103
QTextDocumentPrivate * priv

◆ deleteChar()

void QTextCursor::deleteChar ( )

If there is no selected text, deletes the character at the current cursor position; otherwise deletes the selected text.

See also
deletePreviousChar() hasSelection() clearSelection()

Definition at line 1530 of file qtextcursor.cpp.

Referenced by QLabelPrivate::ensureTextPopulated(), QTextControlPrivate::keyPressEvent(), and QTextEdit::setText().

1531 {
1532  if (!d || !d->priv)
1533  return;
1534 
1535  if (d->position != d->anchor) {
1537  return;
1538  }
1539 
1540  if (!d->canDelete(d->position))
1541  return;
1542  d->adjusted_anchor = d->anchor =
1544  d->remove();
1545  d->setX();
1546 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
void removeSelectedText()
If there is a selection, its content is deleted; otherwise does nothing.
int nextCursorPosition(int position, QTextLayout::CursorMode mode) const
QTextDocumentPrivate * priv
bool canDelete(int pos) const

◆ deletePreviousChar()

void QTextCursor::deletePreviousChar ( )

If there is no selected text, deletes the character before the current cursor position; otherwise deletes the selected text.

See also
deleteChar() hasSelection() clearSelection()

Definition at line 1554 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::keyPressEvent(), QPlainTextEdit::keyReleaseEvent(), QTextEdit::keyReleaseEvent(), and QTextEdit::setText().

1555 {
1556  if (!d || !d->priv)
1557  return;
1558 
1559  if (d->position != d->anchor) {
1561  return;
1562  }
1563 
1564  if (d->anchor < 1 || !d->canDelete(d->anchor-1))
1565  return;
1566  d->anchor--;
1567 
1569  const QTextFragmentData * const frag = fragIt.value();
1570  int fpos = fragIt.position();
1571  QChar uc = d->priv->buffer().at(d->anchor - fpos + frag->stringPosition);
1572  if (d->anchor > fpos && uc.isLowSurrogate()) {
1573  // second half of a surrogate, check if we have the first half as well,
1574  // if yes delete both at once
1575  uc = d->priv->buffer().at(d->anchor - 1 - fpos + frag->stringPosition);
1576  if (uc.isHighSurrogate())
1577  --d->anchor;
1578  }
1579 
1580  d->adjusted_anchor = d->anchor;
1581  d->remove();
1582  d->setX();
1583 }
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
bool isLowSurrogate() const
Returns true if the QChar is the low part of a utf16 surrogate (ie.
Definition: qchar.h:279
bool isHighSurrogate() const
Returns true if the QChar is the high part of a utf16 surrogate (ie.
Definition: qchar.h:276
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
FragmentMap::ConstIterator FragmentIterator
FragmentIterator find(int pos) const
void removeSelectedText()
If there is a selection, its content is deleted; otherwise does nothing.
QString buffer() const
QTextDocumentPrivate * priv
bool canDelete(int pos) const

◆ document()

QTextDocument * QTextCursor::document ( ) const

Returns the document this cursor is associated with.

Since
4.5

Definition at line 2675 of file qtextcursor.cpp.

Referenced by QLabelPrivate::ensureTextPopulated().

2676 {
2677  if (d->priv)
2678  return d->priv->document();
2679  return 0; // document went away
2680 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * priv
QTextDocument * document()

◆ endEditBlock()

void QTextCursor::endEditBlock ( )

Indicates the end of a block of editing operations on the document that should appear as a single operation from an undo/redo point of view.

See also
beginEditBlock()

Definition at line 2593 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::append(), QTextControlPrivate::createAutoBulletList(), QTextEditPrivate::createAutoBulletList(), QTextControlPrivate::dropEvent(), QTextHtmlImporter::import(), QSyntaxHighlighterPrivate::rehighlight(), QDeclarativeTextEdit::select(), QTextControlPrivate::setContent(), QSyntaxHighlighter::setDocument(), QDeclarativeTextEditPrivate::updateSelection(), and QDeclarativeJS::TextWriter::write_helper().

2594 {
2595  if (!d || !d->priv)
2596  return;
2597 
2598  d->priv->endEditBlock();
2599 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * priv

◆ hasComplexSelection()

bool QTextCursor::hasComplexSelection ( ) const

Returns true if the cursor contains a selection that is not simply a range from selectionStart() to selectionEnd(); otherwise returns false.

Complex selections are ones that span at least two cells in a table; their extent is specified by selectedTableCells().

Definition at line 1640 of file qtextcursor.cpp.

Referenced by QTextCopyHelper::copy(), QTextTable::mergeCells(), QTextControlPrivate::repaintOldAndNewSelection(), and QTextControl::selectionRect().

1641 {
1642  if (!d)
1643  return false;
1644 
1645  return d->complexSelectionTable() != 0;
1646 }
QTextTable * complexSelectionTable() const
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230

◆ hasSelection()

bool QTextCursor::hasSelection ( ) const

◆ insertBlock() [1/3]

void QTextCursor::insertBlock ( )

Inserts a new empty block at the cursor position() with the current blockFormat() and charFormat().

See also
setBlockFormat()

Definition at line 2055 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::append(), QTextHtmlImporter::appendBlock(), insertBlock(), insertList(), QTextTable::mergeCells(), and QTextEdit::setText().

2056 {
2058 }
QTextBlockFormat blockFormat() const
Returns the block format of the block the cursor is in.
void insertBlock()
Inserts a new empty block at the cursor position() with the current blockFormat() and charFormat()...

◆ insertBlock() [2/3]

void QTextCursor::insertBlock ( const QTextBlockFormat format)

Inserts a new empty block at the cursor position() with block format format and the current charFormat() as block char format.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
setBlockFormat()

Definition at line 2071 of file qtextcursor.cpp.

2072 {
2073  QTextCharFormat charFmt = charFormat();
2075  insertBlock(format, charFmt);
2076 }
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
QTextCharFormat charFormat() const
Returns the format of the character immediately before the cursor position().
void insertBlock()
Inserts a new empty block at the cursor position() with the current blockFormat() and charFormat()...
void clearProperty(int propertyId)
Clears the value of the property given by propertyId.

◆ insertBlock() [3/3]

void QTextCursor::insertBlock ( const QTextBlockFormat format,
const QTextCharFormat charFormat 
)

Inserts a new empty block at the cursor position() with block format format and charFormat as block char format.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
setBlockFormat()

Definition at line 2090 of file qtextcursor.cpp.

2091 {
2092  if (!d || !d->priv)
2093  return;
2094 
2095  QTextCharFormat charFormat = _charFormat;
2097 
2098  d->priv->beginEditBlock();
2099  d->remove();
2100  d->insertBlock(format, charFormat);
2101  d->priv->endEditBlock();
2102  d->setX();
2103 }
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
void insertBlock(const QTextBlockFormat &format, const QTextCharFormat &charFormat)
QTextDocumentPrivate * priv
void clearProperty(int propertyId)
Clears the value of the property given by propertyId.

◆ insertFragment()

void QTextCursor::insertFragment ( const QTextDocumentFragment fragment)

Inserts the text fragment at the current position().

Definition at line 2289 of file qtextcursor.cpp.

Referenced by QTextDocument::clone(), insertHtml(), and QTextControl::print().

2290 {
2291  if (!d || !d->priv || fragment.isEmpty())
2292  return;
2293 
2294  d->priv->beginEditBlock();
2295  d->remove();
2296  fragment.d->insert(*this);
2297  d->priv->endEditBlock();
2298 
2299  if (fragment.d && fragment.d->doc)
2300  d->priv->mergeCachedResources(fragment.d->doc->docHandle());
2301 }
QTextDocumentFragmentPrivate * d
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * docHandle() const
So that not all classes have to be friends of each other.
bool isEmpty() const
Returns true if the fragment is empty; otherwise returns false.
void insert(QTextCursor &cursor) const
void mergeCachedResources(const QTextDocumentPrivate *priv)
QTextDocumentPrivate * priv

◆ insertFrame()

QTextFrame * QTextCursor::insertFrame ( const QTextFrameFormat format)

Inserts a frame with the given format at the current cursor position(), moves the cursor position() inside the frame, and returns the frame.

If the cursor holds a selection, the whole selection is moved inside the frame.

See also
hasSelection()

Definition at line 2264 of file qtextcursor.cpp.

Referenced by QTextHtmlImporter::scanTable().

2265 {
2266  if (!d || !d->priv)
2267  return 0;
2268 
2269  return d->priv->insertFrame(selectionStart(), selectionEnd(), format);
2270 }
int selectionEnd() const
Returns the end of the selection or position() if the cursor doesn&#39;t have a selection.
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * priv
QTextFrame * insertFrame(int start, int end, const QTextFrameFormat &format)
int selectionStart() const
Returns the start of the selection or position() if the cursor doesn&#39;t have a selection.

◆ insertHtml()

void QTextCursor::insertHtml ( const QString html)

Inserts the text html at the current position().

Since
4.2 The text is interpreted as HTML.
Note
When using this function with a style sheet, the style sheet will only apply to the current block in the document. In order to apply a style sheet throughout a document, use QTextDocument::setDefaultStyleSheet() instead.

Definition at line 2319 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::append().

2320 {
2321  if (!d || !d->priv)
2322  return;
2324  insertFragment(fragment);
2325 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
static QTextDocumentFragment fromHtml(const QString &html)
Returns a QTextDocumentFragment based on the arbitrary piece of HTML in the given text...
void insertFragment(const QTextDocumentFragment &fragment)
Inserts the text fragment at the current position().
QTextDocumentPrivate * priv
The QTextDocumentFragment class represents a piece of formatted text from a QTextDocument.
QTextDocument * document()

◆ insertImage() [1/4]

void QTextCursor::insertImage ( const QTextImageFormat format,
QTextFrameFormat::Position  alignment 
)

Inserts the image defined by the given format at the cursor's current position with the specified alignment.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
4.2
See also
position()

Definition at line 2341 of file qtextcursor.cpp.

Referenced by insertImage(), and QTextHtmlImporter::processSpecialNodes().

2342 {
2343  if (!d || !d->priv)
2344  return;
2345 
2346  QTextFrameFormat ffmt;
2347  ffmt.setPosition(alignment);
2348  QTextObject *obj = d->priv->createObject(ffmt);
2349 
2350  QTextImageFormat fmt = format;
2351  fmt.setObjectIndex(obj->objectIndex());
2352 
2353  d->priv->beginEditBlock();
2354  d->remove();
2355  const int idx = d->priv->formatCollection()->indexForFormat(fmt);
2357  d->priv->endEditBlock();
2358 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
void insert(int pos, const QString &text, int format)
void setPosition(Position f)
Sets the policy for positioning frames with this frame format.
Definition: qtextformat.h:756
The QTextImageFormat class provides formatting information for images in a QTextDocument.
Definition: qtextformat.h:694
int objectIndex() const
Returns the object index of this object.
QTextFormatCollection * formatCollection()
QTextObject * createObject(const QTextFormat &newFormat, int objectIndex=-1)
The QTextFrameFormat class provides formatting information for frames in a QTextDocument.
Definition: qtextformat.h:727
QTextDocumentPrivate * priv
void setObjectIndex(int object)
Sets the format object&#39;s object index.
The QTextObject class is a base class for different kinds of objects that can group parts of a QTextD...
Definition: qtextobject.h:64
int indexForFormat(const QTextFormat &f)

◆ insertImage() [2/4]

void QTextCursor::insertImage ( const QTextImageFormat format)

Inserts the image defined by format at the current position().

Definition at line 2363 of file qtextcursor.cpp.

2364 {
2366 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
void insertText(const QString &text)
Inserts text at the current position, using the current character format.

◆ insertImage() [3/4]

void QTextCursor::insertImage ( const QString name)

Convenience method for inserting the image with the given name at the current position().

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

QImage img = ...
textDocument->addResource(QTextDocument::ImageResource, QUrl("myimage"), img);
cursor.insertImage("myimage");

Definition at line 2379 of file qtextcursor.cpp.

2380 {
2382  format.setName(name);
2383  insertImage(format);
2384 }
void insertImage(const QTextImageFormat &format, QTextFrameFormat::Position alignment)
Inserts the image defined by the given format at the cursor&#39;s current position with the specified ali...
The QTextImageFormat class provides formatting information for images in a QTextDocument.
Definition: qtextformat.h:694
void setName(const QString &name)
Sets the name of the image.
Definition: qtextformat.h:718

◆ insertImage() [4/4]

void QTextCursor::insertImage ( const QImage image,
const QString name = QString() 
)

Convenience function for inserting the given image with an optional name at the current position().

Since
4.5 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 2396 of file qtextcursor.cpp.

2397 {
2398  if (image.isNull()) {
2399  qWarning("QTextCursor::insertImage: attempt to add an invalid image");
2400  return;
2401  }
2402  QString imageName = name;
2403  if (name.isEmpty())
2404  imageName = QString::number(image.serialNumber());
2405  d->priv->document()->addResource(QTextDocument::ImageResource, QUrl(imageName), image);
2407  format.setName(imageName);
2408  insertImage(format);
2409 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
bool isNull() const
Returns true if it is a null image, otherwise returns false.
Definition: qimage.cpp:1542
void insertImage(const QTextImageFormat &format, QTextFrameFormat::Position alignment)
Inserts the image defined by the given format at the cursor&#39;s current position with the specified ali...
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
The QTextImageFormat class provides formatting information for images in a QTextDocument.
Definition: qtextformat.h:694
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void setName(const QString &name)
Sets the name of the image.
Definition: qtextformat.h:718
const char * name
Q_CORE_EXPORT void qWarning(const char *,...)
int serialNumber() const
Returns a number that identifies the contents of this QImage object.
Definition: qimage.cpp:6267
void addResource(int type, const QUrl &name, const QVariant &resource)
Adds the resource resource to the resource cache, using type and name as identifiers.
QTextDocumentPrivate * priv
QTextDocument * document()

◆ insertList() [1/2]

QTextList * QTextCursor::insertList ( const QTextListFormat format)

Inserts a new block at the current position and makes it the first list item of a newly created list with the given format.

Returns the created list.

See also
currentList() createList() insertBlock()

Definition at line 2112 of file qtextcursor.cpp.

2113 {
2114  insertBlock();
2115  return createList(format);
2116 }
QTextList * createList(const QTextListFormat &format)
Creates and returns a new list with the given format, and makes the current paragraph the cursor is i...
void insertBlock()
Inserts a new empty block at the cursor position() with the current blockFormat() and charFormat()...

◆ insertList() [2/2]

QTextList * QTextCursor::insertList ( QTextListFormat::Style  style)

Inserts a new block at the current position and makes it the first list item of a newly created list with the given style.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns the created list.

See also
currentList(), createList(), insertBlock()

Definition at line 2130 of file qtextcursor.cpp.

2131 {
2132  insertBlock();
2133  return createList(style);
2134 }
QTextList * createList(const QTextListFormat &format)
Creates and returns a new list with the given format, and makes the current paragraph the cursor is i...
void insertBlock()
Inserts a new empty block at the cursor position() with the current blockFormat() and charFormat()...

◆ insertTable() [1/2]

QTextTable * QTextCursor::insertTable ( int  rows,
int  columns,
const QTextTableFormat format 
)

Creates a new table with the given number of rows and columns in the specified format, inserts it at the current cursor position() in the document, and returns the table object.

The cursor is moved to the beginning of the first cell.

There must be at least one row and one column in the table.

See also
currentTable()

Definition at line 2220 of file qtextcursor.cpp.

Referenced by insertTable(), and QTextHtmlImporter::scanTable().

2221 {
2222  if(!d || !d->priv || rows == 0 || cols == 0)
2223  return 0;
2224 
2225  int pos = d->position;
2226  QTextTable *t = QTextTablePrivate::createTable(d->priv, d->position, rows, cols, format);
2227  d->setPosition(pos+1);
2228  // ##### what should we do if we have a selection?
2229  d->anchor = d->position;
2230  d->adjusted_anchor = d->anchor;
2231  return t;
2232 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
bool setPosition(int newPosition)
Definition: qtextcursor_p.h:78
The QTextTable class represents a table in a QTextDocument.
Definition: qtexttable.h:103
static QTextTable * createTable(QTextDocumentPrivate *, int pos, int rows, int cols, const QTextTableFormat &tableFormat)
Definition: qtexttable.cpp:364
QTextDocumentPrivate * priv

◆ insertTable() [2/2]

QTextTable * QTextCursor::insertTable ( int  rows,
int  columns 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Creates a new table with the given number of rows and columns, inserts it at the current cursor position() in the document, and returns the table object.

The cursor is moved to the beginning of the first cell.

There must be at least one row and one column in the table.

See also
currentTable()

Definition at line 2203 of file qtextcursor.cpp.

2204 {
2205  return insertTable(rows, cols, QTextTableFormat());
2206 }
QTextTable * insertTable(int rows, int cols, const QTextTableFormat &format)
Creates a new table with the given number of rows and columns in the specified format, inserts it at the current cursor position() in the document, and returns the table object.
The QTextTableFormat class provides formatting information for tables in a QTextDocument.
Definition: qtextformat.h:842

◆ insertText() [1/2]

void QTextCursor::insertText ( const QString text)

Inserts text at the current position, using the current character format.

If there is a selection, the selection is deleted and replaced by text, for example:

cursor.clearSelection();
cursor.insertText("Hello World");

This clears any existing selection, selects the word at the cursor (i.e. from position() forward), and replaces the selection with the phrase "Hello World".

Any ASCII linefeed characters (\n) in the inserted text are transformed into unicode block separators, corresponding to insertBlock() calls.

See also
charFormat() hasSelection()

Definition at line 1439 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::append(), QTextHtmlImporter::appendNodeText(), QDeclarativeJS::TextWriter::doReplace(), QTextDocumentFragment::fromPlainText(), QTextControlPrivate::inputMethodEvent(), insertImage(), QAccessibleTextWidget::insertText(), QTextTable::mergeCells(), QTextDocument::QTextDocument(), QAccessibleTextWidget::replaceText(), QTextDocument::setPlainText(), and QAccessibleTextEdit::setText().

1440 {
1441  QTextCharFormat fmt = charFormat();
1443  insertText(text, fmt);
1444 }
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
QTextCharFormat charFormat() const
Returns the format of the character immediately before the cursor position().
void insertText(const QString &text)
Inserts text at the current position, using the current character format.
void clearProperty(int propertyId)
Clears the value of the property given by propertyId.

◆ insertText() [2/2]

void QTextCursor::insertText ( const QString text,
const QTextCharFormat format 
)

Inserts text at the current position with the given format.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1455 of file qtextcursor.cpp.

1456 {
1457  if (!d || !d->priv)
1458  return;
1459 
1460  Q_ASSERT(_format.isValid());
1461 
1462  QTextCharFormat format = _format;
1464 
1465  bool hasEditBlock = false;
1466 
1467  if (d->anchor != d->position) {
1468  hasEditBlock = true;
1469  d->priv->beginEditBlock();
1470  d->remove();
1471  }
1472 
1473  if (!text.isEmpty()) {
1475  int formatIdx = formats->indexForFormat(format);
1476  Q_ASSERT(formats->format(formatIdx).isCharFormat());
1477 
1478  QTextBlockFormat blockFmt = blockFormat();
1479 
1480 
1481  int textStart = d->priv->text.length();
1482  int blockStart = 0;
1483  d->priv->text += text;
1484  int textEnd = d->priv->text.length();
1485 
1486  for (int i = 0; i < text.length(); ++i) {
1487  QChar ch = text.at(i);
1488 
1489  const int blockEnd = i;
1490 
1491  if (ch == QLatin1Char('\r')
1492  && (i + 1) < text.length()
1493  && text.at(i + 1) == QLatin1Char('\n')) {
1494  ++i;
1495  ch = text.at(i);
1496  }
1497 
1498  if (ch == QLatin1Char('\n')
1499  || ch == QChar::ParagraphSeparator
1500  || ch == QTextBeginningOfFrame
1501  || ch == QTextEndOfFrame
1502  || ch == QLatin1Char('\r')) {
1503 
1504  if (!hasEditBlock) {
1505  hasEditBlock = true;
1506  d->priv->beginEditBlock();
1507  }
1508 
1509  if (blockEnd > blockStart)
1510  d->priv->insert(d->position, textStart + blockStart, blockEnd - blockStart, formatIdx);
1511 
1512  d->insertBlock(blockFmt, format);
1513  blockStart = i + 1;
1514  }
1515  }
1516  if (textStart + blockStart < textEnd)
1517  d->priv->insert(d->position, textStart + blockStart, textEnd - textStart - blockStart, formatIdx);
1518  }
1519  if (hasEditBlock)
1520  d->priv->endEditBlock();
1521  d->setX();
1522 }
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QTextBlockFormat blockFormat() const
Returns the block format of the block the cursor is in.
#define QTextBeginningOfFrame
QTextFormat format(int idx) const
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
void insert(int pos, const QString &text, int format)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QTextFormatCollection * formatCollection()
void insertBlock(const QTextBlockFormat &format, const QTextCharFormat &charFormat)
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument...
Definition: qtextformat.h:545
QTextDocumentPrivate * priv
bool isCharFormat() const
Returns true if this text format is a CharFormat; otherwise returns false.
Definition: qtextformat.h:318
void clearProperty(int propertyId)
Clears the value of the property given by propertyId.
int indexForFormat(const QTextFormat &f)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
#define text
Definition: qobjectdefs.h:80
#define QTextEndOfFrame

◆ isCopyOf()

bool QTextCursor::isCopyOf ( const QTextCursor other) const

Returns true if this cursor and other are copies of each other, i.e.

one of them was created as a copy of the other and neither has moved since. This is much stricter than equality.

See also
operator=() operator==()

Definition at line 2608 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::_q_emitCursorPosChanged().

2609 {
2610  return d == other.d;
2611 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230

◆ isNull()

bool QTextCursor::isNull ( ) const

Returns true if the cursor is null; otherwise returns false.

A null cursor is created by the default constructor.

Definition at line 1153 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::cursorMoveKeyEvent(), QTextControl::cursorRect(), QPlainTextEdit::cursorRect(), QTextEdit::cursorRect(), QTextControlPrivate::cursorRectPlusUnicodeDirectionMarkers(), QTextControl::find(), QTextDocument::find(), QTextDocumentFragmentPrivate::insert(), and QTextControlPrivate::repaintOldAndNewSelection().

1154 {
1155  return !d || !d->priv;
1156 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * priv

◆ joinPreviousEditBlock()

void QTextCursor::joinPreviousEditBlock ( )

Like beginEditBlock() indicates the start of a block of editing operations that should appear as a single operation for undo/redo.

However unlike beginEditBlock() it does not start a new block but reverses the previous call to endEditBlock() and therefore makes following operations part of the previous edit block created.

For example:

QTextCursor cursor(textDocument);
cursor.beginEditBlock();
cursor.insertText("Hello");
cursor.insertText("World");
cursor.endEditBlock();
...
cursor.joinPreviousEditBlock();
cursor.insertText("Hey");
cursor.endEditBlock();
textDocument->undo();

The call to undo() will cause all three insertions to be undone.

See also
beginEditBlock(), endEditBlock()

Definition at line 2577 of file qtextcursor.cpp.

2578 {
2579  if (!d || !d->priv)
2580  return;
2581 
2583 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * priv

◆ keepPositionOnInsert()

bool QTextCursor::keepPositionOnInsert ( ) const

Returns whether the cursor should keep its current position when text gets inserted at the position of the cursor.

Since
4.7

The default is false;

See also
setKeepPositionOnInsert()

Definition at line 1391 of file qtextcursor.cpp.

1392 {
1393  return d ? d->keepPositionOnInsert : false;
1394 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230

◆ mergeBlockCharFormat()

void QTextCursor::mergeBlockCharFormat ( const QTextCharFormat modifier)

Modifies the block char format of the current block (or all blocks that are contained in the selection) with the block format specified by modifier.

See also
setBlockCharFormat()

Definition at line 1898 of file qtextcursor.cpp.

Referenced by QTextHtmlImporter::processBlockNode().

1899 {
1900  if (!d || !d->priv)
1901  return;
1902 
1904 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
void setBlockCharFormat(const QTextCharFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode)
QTextDocumentPrivate * priv

◆ mergeBlockFormat()

void QTextCursor::mergeBlockFormat ( const QTextBlockFormat modifier)

Modifies the block format of the current block (or all blocks that are contained in the selection) with the block format specified by modifier.

See also
setBlockFormat(), blockFormat()

Definition at line 1853 of file qtextcursor.cpp.

Referenced by createList(), QSplashScreen::drawContents(), QTextControlPrivate::indent(), QTextControlPrivate::outdent(), QTextHtmlImporter::processBlockNode(), QTextHtmlImporter::processSpecialNodes(), and QTextEdit::setAlignment().

1854 {
1855  if (!d || !d->priv)
1856  return;
1857 
1859 }
void setBlockFormat(const QTextBlockFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode)
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * priv

◆ mergeCharFormat()

void QTextCursor::mergeCharFormat ( const QTextCharFormat modifier)

Merges the cursor's current character format with the properties described by format modifier.

If the cursor has a selection, this function applies all the properties set in modifier to all the character formats that are part of the selection.

See also
hasSelection(), setCharFormat()

Definition at line 1974 of file qtextcursor.cpp.

Referenced by QTextHtmlImporter::processSpecialNodes().

1975 {
1976  if (!d || !d->priv)
1977  return;
1978  if (d->position == d->anchor) {
1980  format.merge(modifier);
1982  return;
1983  }
1984 
1986 }
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
QTextCharFormat charFormat() const
Returns the format of the character immediately before the cursor position().
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextFormatCollection * formatCollection()
void merge(const QTextFormat &other)
Merges the other format with this format; where there are conflicts the other format takes precedence...
QTextDocumentPrivate * priv
void setCharFormat(const QTextCharFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode)
int indexForFormat(const QTextFormat &f)

◆ movePosition()

bool QTextCursor::movePosition ( MoveOperation  operation,
MoveMode  mode = MoveAnchor,
int  n = 1 
)

Moves the cursor by performing the given operation n times, using the specified mode, and returns true if all operations were completed successfully; otherwise returns false.

For example, if this function is repeatedly used to seek to the end of the next word, it will eventually fail when the end of the document is reached.

By default, the move operation is performed once (n = 1).

If mode is KeepAnchor, the cursor selects the text it moves over. This is the same effect that the user achieves when they hold down the Shift key and move the cursor with the cursor keys.

See also
setVisualNavigation()

Definition at line 1258 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::activateLinkUnderCursor(), QTextControlPrivate::anchorForCursor(), QPlainTextEditPrivate::append(), QTextControlPrivate::append(), QAccessibleTextWidget::characterCount(), QTextControlPrivate::cursorMoveKeyEvent(), QTextDocumentPrivate::ensureMaximumBlockCount(), QLabelPrivate::ensureTextPopulated(), QTextControlPrivate::extendBlockwiseSelection(), QTextControlPrivate::extendWordwiseSelection(), QScriptDebuggerCodeView::find(), QTextDocumentFragmentPrivate::insert(), QDeclarativeTextEdit::moveCursorSelection(), QTextEditPrivate::pageUpDown(), QPlainTextEditPrivate::pageUpDown(), QTextHtmlImporter::processSpecialNodes(), QTextDocumentFragment::QTextDocumentFragment(), QSyntaxHighlighterPrivate::rehighlight(), select(), and QTextEdit::setText().

1259 {
1260  if (!d || !d->priv)
1261  return false;
1262  switch (op) {
1263  case Start:
1264  case StartOfLine:
1265  case End:
1266  case EndOfLine:
1267  n = 1;
1268  break;
1269  default: break;
1270  }
1271 
1272  int previousPosition = d->position;
1273  for (; n > 0; --n) {
1274  if (!d->movePosition(op, mode))
1275  return false;
1276  }
1277 
1278  if (d->visualNavigation && !d->block().isVisible()) {
1279  QTextBlock b = d->block();
1280  if (previousPosition < d->position) {
1281  while (!b.next().isVisible())
1282  b = b.next();
1283  d->setPosition(b.position() + b.length() - 1);
1284  } else {
1285  while (!b.previous().isVisible())
1286  b = b.previous();
1287  d->setPosition(b.position());
1288  }
1289  if (mode == QTextCursor::MoveAnchor)
1290  d->anchor = d->position;
1291  while (d->movePosition(op, mode)
1292  && !d->block().isVisible())
1293  ;
1294 
1295  }
1296  return true;
1297 }
QTextBlock block() const
Definition: qtextcursor_p.h:93
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextBlock next() const
Returns the text block in the document after this block, or an empty text block if this is the last o...
int position() const
Returns the index of the block&#39;s first character within the document.
QTextBlock previous() const
Returns the text block in the document before this block, or an empty text block if this is the first...
bool setPosition(int newPosition)
Definition: qtextcursor_p.h:78
bool isVisible() const
Returns true if the block is visible; otherwise returns false.
bool movePosition(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode=QTextCursor::MoveAnchor)
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
int position() const
Returns the absolute position of the cursor within the document.
int length() const
Returns the length of the block in characters.
QTextDocumentPrivate * priv

◆ operator!=()

bool QTextCursor::operator!= ( const QTextCursor rhs) const

Returns true if the other cursor is at a different position in the document as this cursor; otherwise returns false.

Definition at line 2420 of file qtextcursor.cpp.

2421 {
2422  return !operator==(rhs);
2423 }
bool operator==(const QTextCursor &rhs) const
Returns true if the other cursor is at the same position in the document as this cursor; otherwise re...

◆ operator<()

bool QTextCursor::operator< ( const QTextCursor rhs) const

Returns true if the other cursor is positioned later in the document than this cursor; otherwise returns false.

Definition at line 2434 of file qtextcursor.cpp.

2435 {
2436  if (!d)
2437  return !!rhs.d;
2438 
2439  if (!rhs.d)
2440  return false;
2441 
2442  Q_ASSERT_X(d->priv == rhs.d->priv, "QTextCursor::operator<", "cannot compare cursors attached to different documents");
2443 
2444  return d->position < rhs.d->position;
2445 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
QTextDocumentPrivate * priv

◆ operator<=()

bool QTextCursor::operator<= ( const QTextCursor rhs) const

Returns true if the other cursor is positioned later or at the same position in the document as this cursor; otherwise returns false.

Definition at line 2457 of file qtextcursor.cpp.

2458 {
2459  if (!d)
2460  return true;
2461 
2462  if (!rhs.d)
2463  return false;
2464 
2465  Q_ASSERT_X(d->priv == rhs.d->priv, "QTextCursor::operator<=", "cannot compare cursors attached to different documents");
2466 
2467  return d->position <= rhs.d->position;
2468 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
QTextDocumentPrivate * priv

◆ operator=()

QTextCursor & QTextCursor::operator= ( const QTextCursor cursor)

Makes a copy of cursor and assigns it to this QTextCursor.

Note that QTextCursor is an Implicitly Shared Classes{implicitly shared} class.

Definition at line 1136 of file qtextcursor.cpp.

1137 {
1138  d = cursor.d;
1139  return *this;
1140 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230

◆ operator==()

bool QTextCursor::operator== ( const QTextCursor rhs) const

Returns true if the other cursor is at the same position in the document as this cursor; otherwise returns false.

Definition at line 2479 of file qtextcursor.cpp.

Referenced by operator!=().

2480 {
2481  if (!d)
2482  return !rhs.d;
2483 
2484  if (!rhs.d)
2485  return false;
2486 
2487  return d->position == rhs.d->position && d->priv == rhs.d->priv;
2488 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * priv

◆ operator>()

bool QTextCursor::operator> ( const QTextCursor rhs) const

Returns true if the other cursor is positioned earlier in the document than this cursor; otherwise returns false.

Definition at line 2522 of file qtextcursor.cpp.

2523 {
2524  if (!d)
2525  return false;
2526 
2527  if (!rhs.d)
2528  return true;
2529 
2530  Q_ASSERT_X(d->priv == rhs.d->priv, "QTextCursor::operator>", "cannot compare cursors attached to different documents");
2531 
2532  return d->position > rhs.d->position;
2533 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
QTextDocumentPrivate * priv

◆ operator>=()

bool QTextCursor::operator>= ( const QTextCursor rhs) const

Returns true if the other cursor is positioned earlier or at the same position in the document as this cursor; otherwise returns false.

Definition at line 2500 of file qtextcursor.cpp.

2501 {
2502  if (!d)
2503  return false;
2504 
2505  if (!rhs.d)
2506  return true;
2507 
2508  Q_ASSERT_X(d->priv == rhs.d->priv, "QTextCursor::operator>=", "cannot compare cursors attached to different documents");
2509 
2510  return d->position >= rhs.d->position;
2511 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
QTextDocumentPrivate * priv

◆ position()

int QTextCursor::position ( ) const

Returns the absolute position of the cursor within the document.

The cursor is positioned between characters.

See also
setPosition() movePosition() anchor() positionInBlock()

Definition at line 1196 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::activateLinkUnderCursor(), QTextControlPrivate::anchorForCursor(), QTextHtmlImporter::appendNodeText(), QTextTable::cellAt(), QAccessibleTextWidget::characterCount(), QTextBrowserPrivate::createHistoryEntry(), currentTextLine(), QTextControlPrivate::cursorMoveKeyEvent(), QAccessibleTextWidget::cursorPosition(), QTextControl::cursorRect(), QTextControlPrivate::cursorRectPlusUnicodeDirectionMarkers(), QTextDocumentLayoutPrivate::drawBlock(), QLabelPrivate::ensureTextPopulated(), QScriptDebuggerCodeView::event(), QTextControlPrivate::extendBlockwiseSelection(), QTextControlPrivate::extendWordwiseSelection(), findInBlock(), QTextControlPrivate::inputMethodEvent(), QAccessibleTextEdit::invokeMethodEx(), QTextControlPrivate::mouseMoveEvent(), QTextControlPrivate::mousePressEvent(), QTextControlPrivate::mouseReleaseEvent(), QDeclarativeTextEdit::moveCursorSelection(), movePosition(), QPlainTextEdit::paintEvent(), QDeclarativeTextEdit::positionAt(), QTextHtmlImporter::processBlockNode(), QTextCopyHelper::QTextCopyHelper(), QSyntaxHighlighterPrivate::rehighlight(), QTextControlPrivate::repaintOldAndNewSelection(), QTextHtmlImporter::scanTable(), QDeclarativeTextEdit::setCursorPosition(), QTextControl::setExtraSelections(), QTextEdit::setText(), and QTextControl::setTextCursor().

1197 {
1198  if (!d || !d->priv)
1199  return -1;
1200  return d->position;
1201 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * priv

◆ positionInBlock()

int QTextCursor::positionInBlock ( ) const

Returns the relative position of the cursor within the block.

Since
4.7

The cursor is positioned between characters.

This is equivalent to position() - block().position().

See also
position()

Definition at line 1215 of file qtextcursor.cpp.

1216 {
1217  if (!d || !d->priv)
1218  return 0;
1219  return d->position - d->block().position();
1220 }
QTextBlock block() const
Definition: qtextcursor_p.h:93
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
int position() const
Returns the index of the block&#39;s first character within the document.
QTextDocumentPrivate * priv

◆ removeSelectedText()

void QTextCursor::removeSelectedText ( )

If there is a selection, its content is deleted; otherwise does nothing.

See also
hasSelection()

Definition at line 1691 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::_q_deleteSelected(), QPlainTextEditPrivate::append(), deleteChar(), deletePreviousChar(), QAccessibleTextWidget::deleteText(), QTextDocumentPrivate::ensureMaximumBlockCount(), QAccessibleTextWidget::replaceText(), and QTextControlPrivate::startDrag().

1692 {
1693  if (!d || !d->priv || d->position == d->anchor)
1694  return;
1695 
1696  d->priv->beginEditBlock();
1697  d->remove();
1698  d->priv->endEditBlock();
1699  d->setX();
1700 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * priv

◆ select()

void QTextCursor::select ( SelectionType  selection)

Selects text in the document according to the given selection.

Definition at line 1588 of file qtextcursor.cpp.

Referenced by QSplashScreen::drawContents(), QDeclarativeTextEdit::selectWord(), QTextControlPrivate::setContent(), and QAccessibleTextEdit::setText().

1589 {
1590  if (!d || !d->priv)
1591  return;
1592 
1593  clearSelection();
1594 
1595  const QTextBlock block = d->block();
1596 
1597  switch (selection) {
1598  case LineUnderCursor:
1601  break;
1602  case WordUnderCursor:
1605  break;
1606  case BlockUnderCursor:
1607  if (block.length() == 1) // no content
1608  break;
1610  // also select the paragraph separator
1611  if (movePosition(PreviousBlock)) {
1614  }
1616  break;
1617  case Document:
1620  break;
1621  }
1622 }
QTextBlock block() const
Definition: qtextcursor_p.h:93
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentFragment selection() const
Returns the current selection (which may be empty) with all its formatting information.
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
int length() const
Returns the length of the block in characters.
QTextBlock block() const
Returns the block that contains the cursor.
void clearSelection()
Clears the current selection by setting the anchor to the cursor position.
QTextDocumentPrivate * priv
bool movePosition(MoveOperation op, MoveMode=MoveAnchor, int n=1)
Moves the cursor by performing the given operation n times, using the specified mode, and returns true if all operations were completed successfully; otherwise returns false.

◆ selectedTableCells()

void QTextCursor::selectedTableCells ( int *  firstRow,
int *  numRows,
int *  firstColumn,
int *  numColumns 
) const

If the selection spans over table cells, firstRow is populated with the number of the first row in the selection, firstColumn with the number of the first column in the selection, and numRows and numColumns with the number of rows and columns in the selection.

If the selection does not span any table cells the results are harmless but undefined.

Definition at line 1656 of file qtextcursor.cpp.

Referenced by QTextCopyHelper::copy(), QTextDocumentLayoutPrivate::drawFrame(), QTextTable::mergeCells(), and selectedText().

1657 {
1658  *firstRow = -1;
1659  *firstColumn = -1;
1660  *numRows = -1;
1661  *numColumns = -1;
1662 
1663  if (!d || d->position == d->anchor)
1664  return;
1665 
1666  d->selectedTableCells(firstRow, numRows, firstColumn, numColumns);
1667 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
void selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const

◆ selectedText()

QString QTextCursor::selectedText ( ) const

Returns the current selection's text (which may be empty).

This only returns the text, with no rich text formatting information. If you want a document fragment (i.e. formatted rich text) use selection() instead.

Note
If the selection obtained from an editor spans a line break, the text will contain a Unicode U+2029 paragraph separator character instead of a newline
character. Use QString::replace() to replace these characters with newlines.

Definition at line 1753 of file qtextcursor.cpp.

Referenced by QDeclarativeJS::TextWriter::doMove(), QLabelPrivate::ensureTextPopulated(), and QAccessibleTextWidget::text().

1754 {
1755  if (!d || !d->priv || d->position == d->anchor)
1756  return QString();
1757 
1758  const QString docText = d->priv->buffer();
1759  QString text;
1760 
1761  QTextTable *table = d->complexSelectionTable();
1762  if (table) {
1763  int row_start, col_start, num_rows, num_cols;
1764  selectedTableCells(&row_start, &num_rows, &col_start, &num_cols);
1765 
1766  Q_ASSERT(row_start != -1);
1767  for (int r = row_start; r < row_start + num_rows; ++r) {
1768  for (int c = col_start; c < col_start + num_cols; ++c) {
1769  QTextTableCell cell = table->cellAt(r, c);
1770  int rspan = cell.rowSpan();
1771  int cspan = cell.columnSpan();
1772  if (rspan != 1) {
1773  int cr = cell.row();
1774  if (cr != r)
1775  continue;
1776  }
1777  if (cspan != 1) {
1778  int cc = cell.column();
1779  if (cc != c)
1780  continue;
1781  }
1782 
1783  getText(text, d->priv, docText, cell.firstPosition(), cell.lastPosition());
1784  }
1785  }
1786  } else {
1787  getText(text, d->priv, docText, selectionStart(), selectionEnd());
1788  }
1789 
1790  return text;
1791 }
QTextTable * complexSelectionTable() const
static void getText(QString &text, QTextDocumentPrivate *priv, const QString &docText, int pos, int end)
unsigned char c[8]
Definition: qnumeric_p.h:62
int selectionEnd() const
Returns the end of the selection or position() if the cursor doesn&#39;t have a selection.
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
int rowSpan() const
Returns the number of rows this cell spans.
Definition: qtexttable.cpp:218
void selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const
If the selection spans over table cells, firstRow is populated with the number of the first row in th...
QTextTableCell cellAt(int row, int col) const
Returns the table cell at the given row and column in the table.
Definition: qtexttable.cpp:630
int column() const
Returns the number of the column in the table that contains this cell.
Definition: qtexttable.cpp:201
int row() const
Returns the number of the row in the table that contains this cell.
Definition: qtexttable.cpp:184
The QTextTable class represents a table in a QTextDocument.
Definition: qtexttable.h:103
int firstPosition() const
Returns the first valid position in the document occupied by this cell.
Definition: qtexttable.cpp:273
QString buffer() const
The QTextTableCell class represents the properties of a cell in a QTextTable.
Definition: qtexttable.h:59
QTextDocumentPrivate * priv
int lastPosition() const
Returns the last valid position in the document occupied by this cell.
Definition: qtexttable.cpp:287
int columnSpan() const
Returns the number of columns this cell spans.
Definition: qtexttable.cpp:228
int selectionStart() const
Returns the start of the selection or position() if the cursor doesn&#39;t have a selection.
#define text
Definition: qobjectdefs.h:80

◆ selection()

QTextDocumentFragment QTextCursor::selection ( ) const

Returns the current selection (which may be empty) with all its formatting information.

If you just want the selected text (i.e. plain text) use selectedText() instead.

Note
Unlike QTextDocumentFragment::toPlainText(), selectedText() may include special unicode characters such as QChar::ParagraphSeparator.
See also
QTextDocumentFragment::toPlainText()

Definition at line 1804 of file qtextcursor.cpp.

1805 {
1806  return QTextDocumentFragment(*this);
1807 }
The QTextDocumentFragment class represents a piece of formatted text from a QTextDocument.

◆ selectionEnd()

int QTextCursor::selectionEnd ( ) const

◆ selectionStart()

int QTextCursor::selectionStart ( ) const

◆ setBlockCharFormat()

void QTextCursor::setBlockCharFormat ( const QTextCharFormat format)

Sets the block char format of the current block (or all blocks that are contained in the selection) to format.

See also
blockCharFormat()

Definition at line 1883 of file qtextcursor.cpp.

Referenced by QTextDocumentPrivate::ensureMaximumBlockCount(), and QTextHtmlImporter::processBlockNode().

1884 {
1885  if (!d || !d->priv)
1886  return;
1887 
1889 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
void setBlockCharFormat(const QTextCharFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode)
QTextDocumentPrivate * priv

◆ setBlockFormat()

void QTextCursor::setBlockFormat ( const QTextBlockFormat format)

Sets the block format of the current block (or all blocks that are contained in the selection) to format.

See also
blockFormat(), mergeBlockFormat()

Definition at line 1838 of file qtextcursor.cpp.

Referenced by QTextHtmlImporter::appendNodeText(), QTextControlPrivate::createAutoBulletList(), QTextEditPrivate::createAutoBulletList(), QTextHtmlImporter::import(), QPlainTextEdit::keyReleaseEvent(), QTextEdit::keyReleaseEvent(), and QTextHtmlImporter::processBlockNode().

1839 {
1840  if (!d || !d->priv)
1841  return;
1842 
1844 }
void setBlockFormat(const QTextBlockFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode)
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextDocumentPrivate * priv

◆ setCharFormat()

void QTextCursor::setCharFormat ( const QTextCharFormat format)

Sets the cursor's current character format to the given format.

If the cursor has a selection, the given format is applied to the current selection.

See also
hasSelection(), mergeCharFormat()

Definition at line 1955 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::append(), and QTextControlPrivate::setContent().

1956 {
1957  if (!d || !d->priv)
1958  return;
1959  if (d->position == d->anchor) {
1961  return;
1962  }
1964 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
QTextFormatCollection * formatCollection()
QTextDocumentPrivate * priv
void setCharFormat(const QTextCharFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode)
int indexForFormat(const QTextFormat &f)

◆ setKeepPositionOnInsert()

void QTextCursor::setKeepPositionOnInsert ( bool  b)

Defines whether the cursor should keep its current position when text gets inserted at the current position of the cursor.

Since
4.7

If b is true, the cursor keeps its current position when text gets inserted at the positing of the cursor. If b is false, the cursor moves along with the inserted text.

The default is false.

Note that a cursor always moves when text is inserted before the current position of the cursor, and it always keeps its position when text is inserted after the current position of the cursor.

See also
keepPositionOnInsert()

Definition at line 1415 of file qtextcursor.cpp.

1416 {
1417  if (d)
1418  d->keepPositionOnInsert = b;
1419 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230

◆ setPosition()

void QTextCursor::setPosition ( int  pos,
MoveMode  m = MoveAnchor 
)

Moves the cursor to the absolute position in the document specified by pos using a MoveMode specified by m.

The cursor is positioned between characters.

See also
position() movePosition() anchor()

Definition at line 1165 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::activateLinkUnderCursor(), QTextControlPrivate::anchorForCursor(), QAccessibleTextWidget::attributes(), QTextControl::cursorForPosition(), QDeclarativeJS::TextWriter::doMove(), QDeclarativeJS::TextWriter::doReplace(), QTextControlPrivate::extendBlockwiseSelection(), QTextControlPrivate::extendWordwiseSelection(), QScriptEdit::extraAreaMouseEvent(), findInBlock(), QTextControl::findNextPrevAnchor(), QTextControlPrivate::inputMethodEvent(), QAccessibleTextWidget::insertText(), QDeclarativeTextEdit::moveCursorSelection(), QAccessibleTextEdit::pasteText(), QDeclarativeTextEdit::positionToRectangle(), QTextHtmlImporter::processBlockNode(), QTextDocument::redo(), QTextControlPrivate::repaintOldAndNewSelection(), QTextBrowserPrivate::restoreHistoryEntry(), QTextHtmlImporter::scanTable(), QAccessibleTextEdit::scrollToSubstring(), QDeclarativeTextEdit::select(), QAccessibleTextWidget::setCursorPosition(), QTextControlPrivate::setCursorPosition(), QDeclarativeTextEdit::setCursorPosition(), QAccessibleTextWidget::setSelection(), QLabel::setSelection(), QAccessibleTextWidget::text(), QAccessibleTextWidget::textCursorForRange(), QTextDocument::undo(), and QDeclarativeTextEditPrivate::updateSelection().

1166 {
1167  if (!d || !d->priv)
1168  return;
1169 
1170  if (pos < 0 || pos >= d->priv->length()) {
1171  qWarning("QTextCursor::setPosition: Position '%d' out of range", pos);
1172  return;
1173  }
1174 
1175  d->setPosition(pos);
1176  if (m == MoveAnchor) {
1177  d->anchor = pos;
1178  d->adjusted_anchor = pos;
1179  } else { // keep anchor
1181  if (pos < d->anchor)
1182  op = QTextCursor::Left;
1183  else
1184  op = QTextCursor::Right;
1185  d->adjustCursor(op);
1186  }
1187  d->setX();
1188 }
int anchor() const
Returns the anchor position; this is the same as position() unless there is a selection in which case...
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230
bool setPosition(int newPosition)
Definition: qtextcursor_p.h:78
Q_CORE_EXPORT void qWarning(const char *,...)
QTextDocumentPrivate * priv
void adjustCursor(QTextCursor::MoveOperation m)

◆ setVerticalMovementX()

void QTextCursor::setVerticalMovementX ( int  x)

Sets the visual x position for vertical cursor movements to x.

Since
4.7

The vertical movement x position is cleared automatically when the cursor moves horizontally, and kept unchanged when the cursor moves vertically. The mechanism allows the cursor to move up and down on a visually straight line with proportional fonts, and to gently "jump" over short lines.

A value of -1 indicates no predefined x position. It will then be set automatically the next time the cursor moves up or down.

See also
verticalMovementX()

Definition at line 1355 of file qtextcursor.cpp.

1356 {
1357  if (d)
1358  d->x = x;
1359 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230

◆ setVisualNavigation()

void QTextCursor::setVisualNavigation ( bool  b)

Sets visual navigation to b.

Since
4.4

Visual navigation means skipping over hidden text pragraphs. The default is false.

See also
visualNavigation(), movePosition()

Definition at line 1331 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::cursorMoveKeyEvent(), and QPlainTextEditPrivate::pageUpDown().

1332 {
1333  if (d)
1334  d->visualNavigation = b;
1335 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230

◆ verticalMovementX()

int QTextCursor::verticalMovementX ( ) const

Returns the visual x position for vertical cursor movements.

Since
4.7

A value of -1 indicates no predefined x position. It will then be set automatically the next time the cursor moves up or down.

See also
setVerticalMovementX()

Definition at line 1373 of file qtextcursor.cpp.

1374 {
1375  return d ? d->x : -1;
1376 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230

◆ visualNavigation()

bool QTextCursor::visualNavigation ( ) const

Returns true if the cursor does visual navigation; otherwise returns false.

Since
4.4

Visual navigation means skipping over hidden text pragraphs. The default is false.

See also
setVisualNavigation(), movePosition()

Definition at line 1313 of file qtextcursor.cpp.

Referenced by QTextControlPrivate::cursorMoveKeyEvent().

1314 {
1315  return d ? d->visualNavigation : false;
1316 }
QSharedDataPointer< QTextCursorPrivate > d
Definition: qtextcursor.h:230

Friends and Related Functions

◆ QTextControlPrivate

friend class QTextControlPrivate
friend

Definition at line 233 of file qtextcursor.h.

◆ QTextCopyHelper

friend class QTextCopyHelper
friend

Definition at line 232 of file qtextcursor.h.

◆ QTextDocumentFragmentPrivate

Definition at line 231 of file qtextcursor.h.

Properties

◆ d

QSharedDataPointer<QTextCursorPrivate> QTextCursor::d
private

The documentation for this class was generated from the following files: