poplaae.blogg.se

Text cursors
Text cursors










Text strings can be inserted into the document with the insertText() function, blocks (representing new paragraphs) can be inserted with insertBlock().Įxisting 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. The text at the current character position can be turned into a list using createList().ĭeletions can be achieved using deleteChar(), deletePreviousChar(), and removeSelectedText(). Note that when only a part of a block is selected, the block format is applied to the entire block. If the cursor has a selection, the given format is applied to the current selection. 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. The format of the current character is returned by charFormat(), and the format of the current block is returned by blockFormat().įormatting can be applied to the current text document using the setCharFormat(), mergeCharFormat(), setBlockFormat() and mergeBlockFormat() functions. 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. For selections see selectionStart(), selectionEnd(), hasSelection(), clearSelection(), and removeSelectedText(). The cursor position can be changed programmatically using setPosition() and movePosition() the latter can also be used to select text. If anchor() = position() there is no selection. The text that is between the anchor() and the position() is the selection. Similarly, the "current block" is the block that contains the cursor position().Ī QTextCursor also has an anchor() position. When we refer to "current character" we mean the character immediately before the cursor position() in the document. paragraphs), or within a table's cell, or a list's item, or other structural elements. Some portions of that string can be considered to lie within particular blocks (e.g. 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. 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. A document can be thought of as a single string of characters. 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. QTextCursor contains information about both the cursor's position within a QTextDocument and any selection that it has made. 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. Operator>=(const QTextCursor & other) const Operator(const QTextCursor & other) const Operator!=(const QTextCursor & other) const SetPosition(int pos, QTextCursor::MoveMode m = MoveAnchor) SetCharFormat(const QTextCharFormat & format) SetBlockFormat(const QTextBlockFormat & format) SetBlockCharFormat(const QTextCharFormat & format) SelectedTableCells(int * firstRow, int * numRows, int * firstColumn, int * numColumns) const Select(QTextCursor::SelectionType selection) MovePosition(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode = MoveAnchor, int n = 1) MergeCharFormat(const QTextCharFormat & modifier) MergeBlockFormat(const QTextBlockFormat & modifier) MergeBlockCharFormat(const QTextCharFormat & modifier) IsCopyOf(const QTextCursor & other) const InsertText(const QString & text, const QTextCharFormat & format) InsertTable(int rows, int columns, const QTextTableFormat & format) InsertList(const QTextListFormat & format) InsertImage(const QImage & image, const QString & name = QString()) InsertImage(const QTextImageFormat & format, QTextFrameFormat::Position alignment) InsertImage(const QTextImageFormat & format) InsertFrame(const QTextFrameFormat & format) InsertFragment(const QTextDocumentFragment & fragment) InsertBlock(const QTextBlockFormat & format, const QTextCharFormat & charFormat) InsertBlock(const QTextBlockFormat & format) CreateList(const QTextListFormat & format)












Text cursors