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

    上一话题

    QTextDocumentFragment

    下一话题

    QTextBlock

    QTextFragment

    概要

    函数

    详细描述

    PySide.QtGui.QTextFragment class holds a piece of text in a PySide.QtGui.QTextDocument 采用单 PySide.QtGui.QTextCharFormat .

    A text fragment describes a piece of text that is stored with a single character format. Text in which the character format changes can be represented by sequences of text fragments with different formats.

    If the user edits the text in a fragment and introduces a different character format, the fragment's text will be split at each point where the format changes, and new fragments will be created. For example, changing the style of some text in the middle of a sentence will cause the fragment to be broken into three separate fragments: the first and third with the same format as before, and the second with the new style. The first fragment will contain the text from the beginning of the sentence, the second will contain the text from the middle, and the third takes the text from the end of the sentence.

    ../../_images/qtextfragment-split.png

    A fragment's text and character format can be obtained with the PySide.QtGui.QTextFragment.text() and PySide.QtGui.QTextFragment.charFormat() functions. The PySide.QtGui.QTextFragment.length() function gives the length of the text in the fragment. PySide.QtGui.QTextFragment.position() gives the position in the document of the start of the fragment. To determine whether the fragment contains a particular position within the document, use the PySide.QtGui.QTextFragment.contains() 函数。

    另请参阅

    PySide.QtGui.QTextDocument Rich Text Document Structure

    class PySide.QtGui. QTextFragment
    class PySide.QtGui. QTextFragment ( o )
    参数: o PySide.QtGui.QTextFragment

    Creates a new empty text fragment.

    Copies the content (text and format) of the other text fragment to this text fragment.

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

    Returns the text fragment's character format.

    PySide.QtGui.QTextFragment. charFormatIndex ( )
    返回类型: PySide.QtCore.int

    Returns an index into the document's internal list of character formats for the text fragment's character format.

    PySide.QtGui.QTextFragment. contains ( position )
    参数: position PySide.QtCore.int
    返回类型: PySide.QtCore.bool

    Returns true if the text fragment contains the text at the given position in the document; otherwise returns false.

    PySide.QtGui.QTextFragment. isValid ( )
    返回类型: PySide.QtCore.bool

    Returns true if this is a valid text fragment (i.e. has a valid position in a document); otherwise returns false.

    PySide.QtGui.QTextFragment. length ( )
    返回类型: PySide.QtCore.int

    Returns the number of characters in the text fragment.

    PySide.QtGui.QTextFragment. __ne__ ( o )
    参数: o PySide.QtGui.QTextFragment
    返回类型: PySide.QtCore.bool

    Returns true if this text fragment is different (at a different position) from the other text fragment; otherwise returns false.

    PySide.QtGui.QTextFragment. __lt__ ( o )
    参数: o PySide.QtGui.QTextFragment
    返回类型: PySide.QtCore.bool

    Returns true if this text fragment appears earlier in the document than the other text fragment; otherwise returns false.

    PySide.QtGui.QTextFragment. __eq__ ( o )
    参数: o PySide.QtGui.QTextFragment
    返回类型: PySide.QtCore.bool

    Returns true if this text fragment is the same (at the same position) as the other text fragment; otherwise returns false.

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

    Returns the position of this text fragment in the document.

    PySide.QtGui.QTextFragment. text ( )
    返回类型: unicode

    Returns the text fragment's as plain text.