QTextCursor Class Reference |
Constant | Value | Description |
---|---|---|
QTextCursor::MoveAnchor | 0 | Moves the anchor to the same position as the cursor itself. |
QTextCursor::KeepAnchor | 1 | Keeps the anchor where it is. |
If the anchor() is kept where it is and the position() is moved, the text in between will be selected.
Constant | Value | Description |
---|---|---|
QTextCursor::NoMove | 0 | Keep the cursor where it is |
QTextCursor::Start | 1 | Move to the start of the document. |
QTextCursor::StartOfLine | 3 | Move to the start of the current line. |
QTextCursor::StartOfBlock | 4 | Move to the start of the current block. |
QTextCursor::StartOfWord | 5 | Move to the start of the current word. |
QTextCursor::PreviousBlock | 6 | Move to the start of the previous block. |
QTextCursor::PreviousCharacter | 7 | Move to the previous character. |
QTextCursor::PreviousWord | 8 | Move to the beginning of the previous word. |
QTextCursor::Up | 2 | Move up one line. |
QTextCursor::Left | 9 | Move left one character. |
QTextCursor::WordLeft | 10 | Move left one word. |
QTextCursor::End | 11 | Move to the end of the document. |
QTextCursor::EndOfLine | 13 | Move to the end of the current line. |
QTextCursor::EndOfWord | 14 | Move to the end of the current word. |
QTextCursor::EndOfBlock | 15 | Move to the end of the current block. |
QTextCursor::NextBlock | 16 | Move to the beginning of the next block. |
QTextCursor::NextCharacter | 17 | Move to the next character. |
QTextCursor::NextWord | 18 | Move to the next word. |
QTextCursor::Down | 12 | Move down one line. |
QTextCursor::Right | 19 | Move right one character. |
QTextCursor::WordRight | 20 | Move right one word. |
See also movePosition().
Constant | Value | Description |
---|---|---|
QTextCursor::WordUnderCursor | 0 | Selects the word under the cursor. If the cursor is not positioned within a string of selectable characters, no text is selected. |
QTextCursor::LineUnderCursor | 1 | Selects the line of text under the cursor. |
QTextCursor::BlockUnderCursor | 2 | Selects the block of text under the cursor. |
Constructs a null cursor.
Constructs a cursor pointing to the beginning of the document.
Constructs a cursor pointing to the beginning of the frame.
Constructs a cursor pointing to the beginning of the block.
Constructs a new cursor that is a copy of cursor.
Destroys the QTextCursor.
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(), and selectionEnd().
Returns true if the cursor is at the end of a block; otherwise returns false.
See also atBlockStart() and atEnd().
Returns true if the cursor is at the start of a block; otherwise returns false.
See also atBlockEnd() and atStart().
Returns true if the cursor is at the end of the document; otherwise returns false.
See also atStart() and atBlockEnd().
Returns true if the cursor is at the start of the document; otherwise returns false.
See also atBlockStart() and atEnd().
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.
See also endEditBlock().
Returns the block that contains the cursor.
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 a block.
See also setBlockCharFormat().
Returns the block format of the block the cursor is in.
See also setBlockFormat() and charFormat().
Returns the format of the character immediately before the cursor position().
See also setCharFormat(), insertText(), and blockFormat().
Clears the current selection.
Note that it does not delete the text of the selection.
See also removeSelectedText() and hasSelection().
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() and currentList().
This is an overloaded member function, provided for convenience.
Creates and returns a new list with the given style, making the cursor's current paragraph the first list item.
The style to be used is defined by the QTextListFormat::Style enum.
See also insertList() and currentList().
Returns a pointer to the current frame. Returns 0 if the cursor is invalid.
See also insertFrame().
Returns the current list if the cursor position() is inside a block that is part of a list; otherwise returns 0.
See also insertList() and createList().
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().
If there is no selected text, deletes the character at the current cursor position; otherwise deletes the selected text.
See also deletePreviousChar(), hasSelection(), and clearSelection().
If there is no selected text, deletes the character before the current cursor position; otherwise deletes the selected text.
See also deleteChar(), hasSelection(), and clearSelection().
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().
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().
Returns true if the cursor contains a selection; otherwise returns false.
Inserts a new empty block at the cursor position() with the current blockFormat() and charFormat().
See also setBlockFormat().
This is an overloaded member function, provided for convenience.
Inserts a new empty block at the cursor position() with block format format and the current charFormat() as block char format.
See also setBlockFormat().
This is an overloaded member function, provided for convenience.
Inserts a new empty block at the cursor position() with block format format and charFormat as block char format.
See also setBlockFormat().
Inserts the text fragment at the current position().
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().
Inserts the image defined by format at the current position().
This is an overloaded member function, provided for convenience.
Convenience method for inserting the image with the given name at the current position().
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(), and insertBlock().
This is an overloaded member function, provided for convenience.
Inserts a new block at the current position and makes it the first list item of a newly created list with the given style. Returns the created list.
See also currentList(), createList(), and insertBlock().
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().
This is an overloaded member function, provided for convenience.
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().
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.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor); 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() and hasSelection().
This is an overloaded member function, provided for convenience.
Inserts text at the current position with the given format.
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=() and operator==().
Returns true if the cursor is null; otherwise returns false. A null cursor is created by the default constructor.
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() and endEditBlock().
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().
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().
Applies all the properties set in modifier to all the character formats that are part of the selection. Does nothing if the cursor does not have a selection.
See also hasSelection().
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.
Returns the absolute position of the cursor within the document. The cursor is positioned between characters.
See also setPosition(), movePosition(), and anchor().
If there is a selection, its content is deleted; otherwise does nothing.
See also hasSelection().
Selects text in the document according to the given selection.
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.
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.
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.
Returns the end of the selection or position() if the cursor doesn't have a selection.
See also selectionStart(), position(), and anchor().
Returns the start of the selection or position() if the cursor doesn't have a selection.
See also selectionEnd(), position(), and anchor().
Sets the block char format of the current block (or all blocks that are contained in the selection) to format.
See also blockCharFormat().
Sets the block format of the current block (or all blocks that are contained in the selection) to format.
See also blockFormat().
Set the character format to the given format for the current selection. Does nothing if the cursor does not have a selection.
See also charFormat() and hasSelection().
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(), and anchor().
Returns true if the other cursor is at a different position in the document as this cursor; otherwise returns false.
Returns true if the other cursor is positioned later in the document than this cursor; otherwise returns false.
Returns true if the other cursor is positioned later or at the same position in the document as this cursor; otherwise returns false.
Makes a copy of cursor and assigns it to this QTextCursor.
Returns true if the other cursor is at the same position in the document as this cursor; otherwise returns false.
Returns true if the other cursor is positioned earlier in the document than this cursor; otherwise returns false.
Returns true if the other cursor is positioned earlier or at the same position in the document as this cursor; otherwise returns false.
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 4.1 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com