Table Of Contents

Previous topic

QPalette

Next topic

QTextLine

QTextCursor

Inheritance diagram of QTextCursor

Synopsis

Functions

Detailed Description

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

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. PySide.QtGui.QTextCursor contains information about both the cursor’s position within a PySide.QtGui.QTextDocument and any selection that it has made.

PySide.QtGui.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 PySide.QtGui.QTextCursor.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 PySide.QtGui.QTextCursor.position() in the document. Similarly, the “current block” is the block that contains the cursor PySide.QtGui.QTextCursor.position() .

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

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

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

Formatting can be applied to the current text document using the PySide.QtGui.QTextCursor.setCharFormat() , PySide.QtGui.QTextCursor.mergeCharFormat() , PySide.QtGui.QTextCursor.setBlockFormat() and PySide.QtGui.QTextCursor.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 PySide.QtGui.QTextCursor.createList() .

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

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

Existing fragments of text can be inserted with PySide.QtGui.QTextCursor.insertFragment() but, if you want to insert pieces of text in various formats, it is usually still easier to use PySide.QtGui.QTextCursor.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 PySide.QtGui.QTextCursor.beginEditBlock() and PySide.QtGui.QTextCursor.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 PySide.QtGui.QTextCursor.movePosition() and PySide.QtGui.QTextCursor.deleteChar() limit cursor movement to these valid positions.

See also

Rich Text Processing

class PySide.QtGui.QTextCursor
class PySide.QtGui.QTextCursor(document)
class PySide.QtGui.QTextCursor(frame)
class PySide.QtGui.QTextCursor(block)
class PySide.QtGui.QTextCursor(cursor)
Parameters:

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 .

PySide.QtGui.QTextCursor.MoveMode
Constant Description
QTextCursor.MoveAnchor Moves the anchor to the same position as the cursor itself.
QTextCursor.KeepAnchor Keeps the anchor where it is.

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

PySide.QtGui.QTextCursor.MoveOperation
Constant Description
QTextCursor.NoMove Keep the cursor where it is
QTextCursor.Start Move to the start of the document.
QTextCursor.StartOfLine Move to the start of the current line.
QTextCursor.StartOfBlock Move to the start of the current block.
QTextCursor.StartOfWord Move to the start of the current word.
QTextCursor.PreviousBlock Move to the start of the previous block.
QTextCursor.PreviousCharacter Move to the previous character.
QTextCursor.PreviousWord Move to the beginning of the previous word.
QTextCursor.Up Move up one line.
QTextCursor.Left Move left one character.
QTextCursor.WordLeft Move left one word.
QTextCursor.End Move to the end of the document.
QTextCursor.EndOfLine Move to the end of the current line.
QTextCursor.EndOfWord Move to the end of the current word.
QTextCursor.EndOfBlock Move to the end of the current block.
QTextCursor.NextBlock Move to the beginning of the next block.
QTextCursor.NextCharacter Move to the next character.
QTextCursor.NextWord Move to the next word.
QTextCursor.Down Move down one line.
QTextCursor.Right Move right one character.
QTextCursor.WordRight Move right one word.
QTextCursor.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.
QTextCursor.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.
QTextCursor.NextRow Move to the first new cell of the next row in the current table.
QTextCursor.PreviousRow Move to the last cell of the previous row in the current table.
PySide.QtGui.QTextCursor.SelectionType

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

Constant Description
QTextCursor.Document Selects the entire document.
QTextCursor.BlockUnderCursor Selects the block of text under the cursor.
QTextCursor.LineUnderCursor Selects the line of text under the cursor.
QTextCursor.WordUnderCursor Selects the word under the cursor. If the cursor is not positioned within a string of selectable characters, no text is selected.
PySide.QtGui.QTextCursor.anchor()
Return type:PySide.QtCore.int

Returns the anchor position; this is the same as PySide.QtGui.QTextCursor.position() unless there is a selection in which case PySide.QtGui.QTextCursor.position() marks one end of the selection and PySide.QtGui.QTextCursor.anchor() marks the other end. Just like the cursor position, the anchor position is between characters.

PySide.QtGui.QTextCursor.atBlockEnd()
Return type:PySide.QtCore.bool

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

PySide.QtGui.QTextCursor.atBlockStart()
Return type:PySide.QtCore.bool

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

PySide.QtGui.QTextCursor.atEnd()
Return type:PySide.QtCore.bool

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

PySide.QtGui.QTextCursor.atStart()
Return type:PySide.QtCore.bool

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

PySide.QtGui.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:

cursor = QTextCursor(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.

PySide.QtGui.QTextCursor.block()
Return type:PySide.QtGui.QTextBlock

Returns the block that contains the cursor.

PySide.QtGui.QTextCursor.blockCharFormat()
Return type:PySide.QtGui.QTextCharFormat

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.

PySide.QtGui.QTextCursor.blockFormat()
Return type:PySide.QtGui.QTextBlockFormat

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

PySide.QtGui.QTextCursor.blockNumber()
Return type:PySide.QtCore.int

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

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

PySide.QtGui.QTextCursor.charFormat()
Return type:PySide.QtGui.QTextCharFormat

Returns the format of the character immediately before the cursor PySide.QtGui.QTextCursor.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.

PySide.QtGui.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.

PySide.QtGui.QTextCursor.columnNumber()
Return type:PySide.QtCore.int

Returns the position of the cursor within its containing line.

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 PySide.QtGui.QTextCursor.positionInBlock() instead.

PySide.QtGui.QTextCursor.createList(style)
Parameters:stylePySide.QtGui.QTextListFormat.Style
Return type:PySide.QtGui.QTextList
PySide.QtGui.QTextCursor.createList(format)
Parameters:formatPySide.QtGui.QTextListFormat
Return type:PySide.QtGui.QTextList

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

PySide.QtGui.QTextCursor.currentFrame()
Return type:PySide.QtGui.QTextFrame

Returns a pointer to the current frame. Returns 0 if the cursor is invalid.

PySide.QtGui.QTextCursor.currentList()
Return type:PySide.QtGui.QTextList

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

PySide.QtGui.QTextCursor.currentTable()
Return type:PySide.QtGui.QTextTable

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

PySide.QtGui.QTextCursor.deleteChar()

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

PySide.QtGui.QTextCursor.deletePreviousChar()

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

PySide.QtGui.QTextCursor.document()
Return type:PySide.QtGui.QTextDocument

Returns the document this cursor is associated with.

PySide.QtGui.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.

PySide.QtGui.QTextCursor.hasComplexSelection()
Return type:PySide.QtCore.bool

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

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

PySide.QtGui.QTextCursor.hasSelection()
Return type:PySide.QtCore.bool

Returns true if the cursor contains a selection; otherwise returns false.

PySide.QtGui.QTextCursor.insertBlock(format, charFormat)
Parameters:

This is an overloaded function.

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

PySide.QtGui.QTextCursor.insertBlock(format)
Parameters:formatPySide.QtGui.QTextBlockFormat

This is an overloaded function.

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

PySide.QtGui.QTextCursor.insertBlock()

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

PySide.QtGui.QTextCursor.insertFragment(fragment)
Parameters:fragmentPySide.QtGui.QTextDocumentFragment

Inserts the text fragment at the current PySide.QtGui.QTextCursor.position() .

PySide.QtGui.QTextCursor.insertFrame(format)
Parameters:formatPySide.QtGui.QTextFrameFormat
Return type:PySide.QtGui.QTextFrame

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

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

PySide.QtGui.QTextCursor.insertHtml(html)
Parameters:html – unicode

Inserts the text html at the current PySide.QtGui.QTextCursor.position() . 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.

PySide.QtGui.QTextCursor.insertImage(format, alignment)
Parameters:
PySide.QtGui.QTextCursor.insertImage(format)
Parameters:formatPySide.QtGui.QTextImageFormat

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

PySide.QtGui.QTextCursor.insertImage(image[, name=""])
Parameters:

This is an overloaded function.

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

PySide.QtGui.QTextCursor.insertImage(name)
Parameters:name – unicode

This is an overloaded function.

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

img = ... # A QImage
textDocument.addResource(QTextDocument.ImageResource, QUrl("myimage"), img)
cursor.insertImage("myimage")
PySide.QtGui.QTextCursor.insertList(format)
Parameters:formatPySide.QtGui.QTextListFormat
Return type:PySide.QtGui.QTextList

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.

PySide.QtGui.QTextCursor.insertList(style)
Parameters:stylePySide.QtGui.QTextListFormat.Style
Return type:PySide.QtGui.QTextList
PySide.QtGui.QTextCursor.insertTable(rows, cols)
Parameters:
  • rowsPySide.QtCore.int
  • colsPySide.QtCore.int
Return type:

PySide.QtGui.QTextTable

This is an overloaded function.

Creates a new table with the given number of rows and columns , inserts it at the current cursor PySide.QtGui.QTextCursor.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.

PySide.QtGui.QTextCursor.insertTable(rows, cols, format)
Parameters:
Return type:

PySide.QtGui.QTextTable

Creates a new table with the given number of rows and columns in the specified format , inserts it at the current cursor PySide.QtGui.QTextCursor.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.

PySide.QtGui.QTextCursor.insertText(text)
Parameters:text – unicode

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 PySide.QtGui.QTextCursor.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 PySide.QtGui.QTextCursor.insertBlock() calls.

PySide.QtGui.QTextCursor.insertText(text, format)
Parameters:

This is an overloaded function.

Inserts text at the current position with the given format .

PySide.QtGui.QTextCursor.isCopyOf(other)
Parameters:otherPySide.QtGui.QTextCursor
Return type:PySide.QtCore.bool

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

PySide.QtGui.QTextCursor.operator=() PySide.QtGui.QTextCursor.operator==()

PySide.QtGui.QTextCursor.isNull()
Return type:PySide.QtCore.bool

Returns true if the cursor is null; otherwise returns false. A null cursor is created by the default constructor.

PySide.QtGui.QTextCursor.joinPreviousEditBlock()

Like PySide.QtGui.QTextCursor.beginEditBlock() indicates the start of a block of editing operations that should appear as a single operation for undo/redo. However unlike PySide.QtGui.QTextCursor.beginEditBlock() it does not start a new block but reverses the previous call to PySide.QtGui.QTextCursor.endEditBlock() and therefore makes following operations part of the previous edit block created.

For example:

cursor = QTextCursor(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.

PySide.QtGui.QTextCursor.keepPositionOnInsert()
Return type:PySide.QtCore.bool

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

The default is false;

PySide.QtGui.QTextCursor.mergeBlockCharFormat(modifier)
Parameters:modifierPySide.QtGui.QTextCharFormat

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 .

PySide.QtGui.QTextCursor.mergeBlockFormat(modifier)
Parameters:modifierPySide.QtGui.QTextBlockFormat

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

PySide.QtGui.QTextCursor.mergeCharFormat(modifier)
Parameters:modifierPySide.QtGui.QTextCharFormat

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.

PySide.QtGui.QTextCursor.movePosition(op[, arg__2=MoveAnchor[, n=1]])
Parameters:
Return type:

PySide.QtCore.bool

Moves the cursor by performing the given operationn 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.

PySide.QtGui.QTextCursor.__ne__(rhs)
Parameters:rhsPySide.QtGui.QTextCursor
Return type:PySide.QtCore.bool

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

PySide.QtGui.QTextCursor.__lt__(rhs)
Parameters:rhsPySide.QtGui.QTextCursor
Return type:PySide.QtCore.bool

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

PySide.QtGui.QTextCursor.__le__(rhs)
Parameters:rhsPySide.QtGui.QTextCursor
Return type:PySide.QtCore.bool

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

PySide.QtGui.QTextCursor.__eq__(rhs)
Parameters:rhsPySide.QtGui.QTextCursor
Return type:PySide.QtCore.bool

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

PySide.QtGui.QTextCursor.__gt__(rhs)
Parameters:rhsPySide.QtGui.QTextCursor
Return type:PySide.QtCore.bool

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

PySide.QtGui.QTextCursor.__ge__(rhs)
Parameters:rhsPySide.QtGui.QTextCursor
Return type:PySide.QtCore.bool

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

PySide.QtGui.QTextCursor.position()
Return type:PySide.QtCore.int

Returns the absolute position of the cursor within the document. The cursor is positioned between characters.

PySide.QtGui.QTextCursor.positionInBlock()
Return type:PySide.QtCore.int

Returns the relative position of the cursor within the block. The cursor is positioned between characters.

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

PySide.QtGui.QTextCursor.removeSelectedText()

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

PySide.QtGui.QTextCursor.select(selection)
Parameters:selectionPySide.QtGui.QTextCursor.SelectionType

Selects text in the document according to the given selection .

PySide.QtGui.QTextCursor.selectedTableCells()

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.

PySide.QtGui.QTextCursor.selectedText()
Return type:unicode

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 PySide.QtGui.QTextCursor.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 \n character. Use QString.replace() to replace these characters with newlines.

PySide.QtGui.QTextCursor.selection()
Return type:PySide.QtGui.QTextDocumentFragment

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 PySide.QtGui.QTextCursor.selectedText() instead.

Note

Unlike QTextDocumentFragment.toPlainText() , PySide.QtGui.QTextCursor.selectedText() may include special unicode characters such as QChar.ParagraphSeparator .

PySide.QtGui.QTextCursor.selectionEnd()
Return type:PySide.QtCore.int

Returns the end of the selection or PySide.QtGui.QTextCursor.position() if the cursor doesn’t have a selection.

PySide.QtGui.QTextCursor.selectionStart()
Return type:PySide.QtCore.int

Returns the start of the selection or PySide.QtGui.QTextCursor.position() if the cursor doesn’t have a selection.

PySide.QtGui.QTextCursor.setBlockCharFormat(format)
Parameters:formatPySide.QtGui.QTextCharFormat

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

PySide.QtGui.QTextCursor.setBlockFormat(format)
Parameters:formatPySide.QtGui.QTextBlockFormat

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

PySide.QtGui.QTextCursor.setCharFormat(format)
Parameters:formatPySide.QtGui.QTextCharFormat

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.

PySide.QtGui.QTextCursor.setKeepPositionOnInsert(b)
Parameters:bPySide.QtCore.bool

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

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.

PySide.QtGui.QTextCursor.setPosition(pos[, mode=MoveAnchor])
Parameters:

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.

PySide.QtGui.QTextCursor.setVerticalMovementX(x)
Parameters:xPySide.QtCore.int

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

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.

PySide.QtGui.QTextCursor.setVisualNavigation(b)
Parameters:bPySide.QtCore.bool

Sets visual navigation to b .

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

PySide.QtGui.QTextCursor.verticalMovementX()
Return type:PySide.QtCore.int

Returns the visual x position for vertical cursor movements.

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

PySide.QtGui.QTextCursor.visualNavigation()
Return type:PySide.QtCore.bool

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

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