• PySide 模块
  • PySide.QtGui
  • 内容表

    上一话题

    QWidgetItem

    下一话题

    QTextFormat

    QTextCursor

    概要

    函数

    详细描述

    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 及它所做的任何选择。

    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() PySide.QtGui.QTextCursor.position() is the selection. If PySide.QtGui.QTextCursor.anchor() == PySide.QtGui.QTextCursor.position() there is no selection.

    光标位置可以通过编程方式被改变,使用 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() ,和 PySide.QtGui.QTextCursor.removeSelectedText() .

    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() .

    格式化可以被应用到当前文本文档使用 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() .

    删除可以达成使用 PySide.QtGui.QTextCursor.deleteChar() , PySide.QtGui.QTextCursor.deletePreviousChar() ,和 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.

    另请参阅

    富文本处理

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

    构造 null 光标。

    构造指向起始的光标为 document .

    构造指向起始的光标为 frame .

    构造指向起始的光标为 block .

    构造新副本光标为 cursor .

    PySide.QtGui.QTextCursor. MoveMode
    常量 描述
    QTextCursor.MoveAnchor 将锚点移到如光标自身的相同位置。
    QTextCursor.KeepAnchor 保持锚点位置。

    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
    常量 描述
    QTextCursor.NoMove 保持光标位置
    QTextCursor.Start 移至文档开头。
    QTextCursor.StartOfLine 移至当前行开头。
    QTextCursor.StartOfBlock 移至当前块开头。
    QTextCursor.StartOfWord 移至当前单词开头。
    QTextCursor.PreviousBlock 移至先前块开头。
    QTextCursor.PreviousCharacter 移至上一字符。
    QTextCursor.PreviousWord 移至先前单词开头。
    QTextCursor.Up 上移一行。
    QTextCursor.Left 左移一字符。
    QTextCursor.WordLeft 左移一单词。
    QTextCursor.End 移至文档末尾。
    QTextCursor.EndOfLine 移至当前行末尾。
    QTextCursor.EndOfWord 移至当前单词末尾。
    QTextCursor.EndOfBlock 移至当前块末尾。
    QTextCursor.NextBlock 移至下一块起始。
    QTextCursor.NextCharacter 移至下一字符。
    QTextCursor.NextWord 移至下一单词。
    QTextCursor.Down 下移一行。
    QTextCursor.Right 右移一字符。
    QTextCursor.WordRight 右移一单词。
    QTextCursor.NextCell 移到当前表格下一表格单元格的起始。若当前单元格是行的最后单元格,则光标移到下一行的第一单元格。
    QTextCursor.PreviousCell 移到当前表格上一表格单元格的起始。若当前单元格是行的第一单元格,则光标将移到上一行的最后单元格。
    QTextCursor.NextRow 移到当前表格下一行的第一新单元格。
    QTextCursor.PreviousRow 移到当前表格上一行的最后单元格。
    PySide.QtGui.QTextCursor. SelectionType

    此枚举描述的选定类型可应用于 PySide.QtGui.QTextCursor.select() 函数。

    常量 描述
    QTextCursor.Document 选择整个文档。
    QTextCursor.BlockUnderCursor 选择光标下的文本块。
    QTextCursor.LineUnderCursor 选择光标下的文本行。
    QTextCursor.WordUnderCursor 选择光标下的单词。若光标不在可选字符的字符串内,则不选择文本。
    PySide.QtGui.QTextCursor. anchor ( )
    返回类型: PySide.QtCore.int

    返回锚点位置;这如同 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 ( )
    返回类型: PySide.QtCore.bool

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

    PySide.QtGui.QTextCursor. atBlockStart ( )
    返回类型: PySide.QtCore.bool

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

    PySide.QtGui.QTextCursor. atEnd ( )
    返回类型: PySide.QtCore.bool

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

    PySide.QtGui.QTextCursor. atStart ( )
    返回类型: PySide.QtCore.bool

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

    PySide.QtGui.QTextCursor. beginEditBlock ( )

    开始在文档中编辑操作块的指示,这应该作为单一操作出现 (从撤销/重做角度来看)。

    例如:

    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 ( )
    返回类型: PySide.QtGui.QTextBlock

    返回包含光标的块。

    PySide.QtGui.QTextCursor. blockCharFormat ( )
    返回类型: PySide.QtGui.QTextCharFormat

    返回光标所在块的块字符格式。

    块字符格式是所用格式,当在空块开头插入文本时。

    PySide.QtGui.QTextCursor. blockFormat ( )
    返回类型: PySide.QtGui.QTextBlockFormat

    返回光标所在块的块格式。

    PySide.QtGui.QTextCursor. blockNumber ( )
    返回类型: PySide.QtCore.int

    返回光标所在块的编号,或 0 若光标无效。

    注意:此函数在文档中才有意义,没有复杂对象 (譬如:表格或框架)。

    PySide.QtGui.QTextCursor. charFormat ( )
    返回类型: PySide.QtGui.QTextCharFormat

    立即返回光标之前的字符格式,在 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 ( )

    清零当前选定,通过把锚点设置到光标位置。

    Note that it does not 删除选定的文本。

    PySide.QtGui.QTextCursor. columnNumber ( )
    返回类型: PySide.QtCore.int

    返回在其包含行内的光标位置。

    注意:这是相对于换行而不是相对于块 (即:段落) 的列号。

    可能想要调用 PySide.QtGui.QTextCursor.positionInBlock() 代替。

    PySide.QtGui.QTextCursor. createList ( style )
    参数: style PySide.QtGui.QTextListFormat.Style
    返回类型: PySide.QtGui.QTextList
    PySide.QtGui.QTextCursor. createList ( format )
    参数: format PySide.QtGui.QTextListFormat
    返回类型: PySide.QtGui.QTextList

    创建并返回新列表采用给定 format ,并使当前段落光标位于第一列表项。

    PySide.QtGui.QTextCursor. currentFrame ( )
    返回类型: PySide.QtGui.QTextFrame

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

    PySide.QtGui.QTextCursor. currentList ( )
    返回类型: PySide.QtGui.QTextList

    返回当前列表若光标 PySide.QtGui.QTextCursor.position() is inside a block that is part of a list; otherwise returns 0.

    PySide.QtGui.QTextCursor. currentTable ( )
    返回类型: PySide.QtGui.QTextTable

    返回当前表格指针若光标 PySide.QtGui.QTextCursor.position() is inside a block that is part of a table; otherwise returns 0.

    PySide.QtGui.QTextCursor. deleteChar ( )

    若没有选中文本,删除字符 at 当前光标位置;否则删除选中文本。

    PySide.QtGui.QTextCursor. deletePreviousChar ( )

    若没有选中文本,删除字符 before 当前光标位置;否则删除选中文本。

    PySide.QtGui.QTextCursor. document ( )
    返回类型: PySide.QtGui.QTextDocument

    返回关联此光标的文档。

    PySide.QtGui.QTextCursor. endEditBlock ( )

    指示应出现作为单操作的文档块编辑操作结束,从撤消/重做角度来看。

    PySide.QtGui.QTextCursor. hasComplexSelection ( )
    返回类型: 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() ;否则返回 false。

    复杂选定是跨越表格至少 2 单元格的选择;其范围被指定通过 PySide.QtGui.QTextCursor.selectedTableCells() .

    PySide.QtGui.QTextCursor. hasSelection ( )
    返回类型: PySide.QtCore.bool

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

    PySide.QtGui.QTextCursor. insertBlock ( format , charFormat )
    参数:

    这是重载函数。

    插入新的空块在光标 PySide.QtGui.QTextCursor.position() with block format format and charFormat 作为块字符格式。

    PySide.QtGui.QTextCursor. insertBlock ( format )
    参数: format PySide.QtGui.QTextBlockFormat

    这是重载函数。

    插入新的空块在光标 PySide.QtGui.QTextCursor.position() with block format format 和当前 PySide.QtGui.QTextCursor.charFormat() 作为块字符格式。

    PySide.QtGui.QTextCursor. insertBlock ( )

    插入新的空块在光标 PySide.QtGui.QTextCursor.position() with the current PySide.QtGui.QTextCursor.blockFormat() and PySide.QtGui.QTextCursor.charFormat() .

    PySide.QtGui.QTextCursor. insertFragment ( fragment )
    参数: fragment PySide.QtGui.QTextDocumentFragment

    插入文本 fragment 在当前 PySide.QtGui.QTextCursor.position() .

    PySide.QtGui.QTextCursor. insertFrame ( format )
    参数: format PySide.QtGui.QTextFrameFormat
    返回类型: PySide.QtGui.QTextFrame

    插入框架采用给定 format 在当前光标 PySide.QtGui.QTextCursor.position() , moves the cursor PySide.QtGui.QTextCursor.position() inside the frame, and returns the frame.

    若光标保有选定,整个选定被移入框架。

    PySide.QtGui.QTextCursor. insertHtml ( html )
    参数: html – unicode

    插入文本 html 在当前 PySide.QtGui.QTextCursor.position() . The text is interpreted as HTML.

    注意

    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() 代替。

    PySide.QtGui.QTextCursor. insertImage ( format , alignment )
    参数:
    PySide.QtGui.QTextCursor. insertImage ( format )
    参数: format PySide.QtGui.QTextImageFormat

    插入图像定义通过 format 在当前 PySide.QtGui.QTextCursor.position() .

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

    这是重载函数。

    方便函数用于插入给定 image 采用可选 name 在当前 PySide.QtGui.QTextCursor.position() .

    PySide.QtGui.QTextCursor. insertImage ( name )
    参数: name – unicode

    这是重载函数。

    用于插入图像的方便方法采用给定 name 在当前 PySide.QtGui.QTextCursor.position() .

    img = ... # A QImage
    textDocument.addResource(QTextDocument.ImageResource, QUrl("myimage"), img)
    cursor.insertImage("myimage")
    											
    PySide.QtGui.QTextCursor. insertList ( format )
    参数: format PySide.QtGui.QTextListFormat
    返回类型: 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 )
    参数: style PySide.QtGui.QTextListFormat.Style
    返回类型: PySide.QtGui.QTextList
    PySide.QtGui.QTextCursor. insertTable ( rows , cols )
    参数:
    • rows PySide.QtCore.int
    • cols PySide.QtCore.int
    返回类型:

    PySide.QtGui.QTextTable

    这是重载函数。

    创建新表采用给定数量的 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 )
    参数:
    返回类型:

    PySide.QtGui.QTextTable

    创建新表采用给定数量的 rows and columns 以指定 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 )
    参数: text – unicode

    插入 text 在当前位置,使用当前字符格式。

    若存在选定,选定被删除并替换通过 text ,例如:

    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() 调用。

    PySide.QtGui.QTextCursor. insertText ( text , format )
    参数:

    这是重载函数。

    插入 text 在当前位置采用给定 format .

    PySide.QtGui.QTextCursor. isCopyOf ( other )
    参数: other PySide.QtGui.QTextCursor
    返回类型: 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.

    另请参阅

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

    PySide.QtGui.QTextCursor. isNull ( )
    返回类型: 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 ( )

    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.

    例如:

    cursor = QTextCursor(textDocument)
    cursor.beginEditBlock()
    cursor.insertText("Hello")
    cursor.insertText("World")
    cursor.endEditBlock()
    ...
    cursor.joinPreviousEditBlock()
    cursor.insertText("Hey")
    cursor.endEditBlock()
    textDocument.undo()
    											

    调用 undo() 将导致所有 3 插入被撤消。

    PySide.QtGui.QTextCursor. keepPositionOnInsert ( )
    返回类型: PySide.QtCore.bool

    返回是否应该保持光标在当前位置,当将文本插入在光标位置处时。

    默认为 false;

    PySide.QtGui.QTextCursor. mergeBlockCharFormat ( modifier )
    参数: modifier PySide.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 )
    参数: modifier PySide.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 )
    参数: modifier PySide.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 ] ] )
    参数:
    返回类型:

    PySide.QtCore.bool

    移动光标通过履行给定 operation n 次,使用指定 mode , and returns true if all operations were completed successfully; otherwise returns false.

    例如:若重复使用此函数以寻址下一单词的末尾,它最终将失败,当到达文档末尾时。

    默认情况下,移动操作被履行一次 ( n = 1).

    mode is KeepAnchor ,光标选择由它移动覆盖的文本。这与用户达成的效果相同,当按下 Shift 键和采用光标键移动光标时。

    PySide.QtGui.QTextCursor. __ne__ ( rhs )
    参数: rhs PySide.QtGui.QTextCursor
    返回类型: PySide.QtCore.bool

    返回 true 若 other cursor is at a different position in the document as this cursor; otherwise returns false.

    PySide.QtGui.QTextCursor. __lt__ ( rhs )
    参数: rhs PySide.QtGui.QTextCursor
    返回类型: PySide.QtCore.bool

    返回 true 若 other cursor is positioned later in the document than this cursor; otherwise returns false.

    PySide.QtGui.QTextCursor. __le__ ( rhs )
    参数: rhs PySide.QtGui.QTextCursor
    返回类型: PySide.QtCore.bool

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

    PySide.QtGui.QTextCursor. __eq__ ( rhs )
    参数: rhs PySide.QtGui.QTextCursor
    返回类型: PySide.QtCore.bool

    返回 true 若 other cursor is at the same position in the document as this cursor; otherwise returns false.

    PySide.QtGui.QTextCursor. __gt__ ( rhs )
    参数: rhs PySide.QtGui.QTextCursor
    返回类型: PySide.QtCore.bool

    返回 true 若 other cursor is positioned earlier in the document than this cursor; otherwise returns false.

    PySide.QtGui.QTextCursor. __ge__ ( rhs )
    参数: rhs PySide.QtGui.QTextCursor
    返回类型: PySide.QtCore.bool

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

    PySide.QtGui.QTextCursor. position ( )
    返回类型: PySide.QtCore.int

    返回光标在文档中的绝对位置。光标位于字符之间。

    PySide.QtGui.QTextCursor. positionInBlock ( )
    返回类型: PySide.QtCore.int

    返回块内光标的相对位置。光标位于字符之间。

    这相当于 position() - block().position() .

    PySide.QtGui.QTextCursor. removeSelectedText ( )

    若存在选定,其内容被删除;否则什么都不做。

    PySide.QtGui.QTextCursor. select ( selection )
    参数: selection PySide.QtGui.QTextCursor.SelectionType

    选择文档文本,根据给定 selection .

    PySide.QtGui.QTextCursor. selectedTableCells ( )

    若选择跨越表格单元格, firstRow 是第一选定行的填充编号, firstColumn 是第一选定列的编号,而 numRows and numColumns 是选定行数和列数。若选定未跨越任何表格单元格,则结果是无害的但不确定。

    PySide.QtGui.QTextCursor. selectedText ( )
    返回类型: unicode

    返回当前选定文本 (可能为空)。这仅返回文本,没有富文本格式化信息。若想要文档片段 (即:格式化的富文本),使用 PySide.QtGui.QTextCursor.selection() 代替。

    注意

    若从编辑器获得的选定跨越换行符,文本将包含 Unicode U+2029 段落分隔符,而不是换行 \n 字符。使用 QString.replace() to replace these characters with newlines.

    PySide.QtGui.QTextCursor. selection ( )
    返回类型: PySide.QtGui.QTextDocumentFragment

    返回当前选定 (可能为空) 自带其所有格式信息。若仅仅希望选择文本 (即:纯文本),使用 PySide.QtGui.QTextCursor.selectedText() 代替。

    注意

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

    PySide.QtGui.QTextCursor. selectionEnd ( )
    返回类型: PySide.QtCore.int

    返回选定的结束,或 PySide.QtGui.QTextCursor.position() if the cursor doesn't have a selection.

    PySide.QtGui.QTextCursor. selectionStart ( )
    返回类型: PySide.QtCore.int

    返回选定的起始,或 PySide.QtGui.QTextCursor.position() if the cursor doesn't have a selection.

    PySide.QtGui.QTextCursor. setBlockCharFormat ( format )
    参数: format PySide.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 )
    参数: format PySide.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 )
    参数: format PySide.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 )
    参数: b PySide.QtCore.bool

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

    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.

    默认为 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 ] )
    参数:

    移动光标到文档绝对位置,指定通过 pos 使用 MoveMode 指定通过 m . The cursor is positioned between characters.

    PySide.QtGui.QTextCursor. setVerticalMovementX ( x )
    参数: x PySide.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 )
    参数: b PySide.QtCore.bool

    把视觉导航设为 b .

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

    PySide.QtGui.QTextCursor. verticalMovementX ( )
    返回类型: 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 ( )
    返回类型: 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.