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

    上一话题

    QTextCursor

    下一话题

    QTextFrameFormat

    QTextFormat

    继承者: QTextFrameFormat , QTextTableFormat , QTextListFormat , QTextBlockFormat , QTextCharFormat , QTextTableCellFormat , QTextImageFormat

    概要

    函数

    详细描述

    PySide.QtGui.QTextFormat class provides formatting information for a PySide.QtGui.QTextDocument .

    A PySide.QtGui.QTextFormat is a generic class used for describing the format of parts of a PySide.QtGui.QTextDocument . The derived classes PySide.QtGui.QTextCharFormat , PySide.QtGui.QTextBlockFormat , PySide.QtGui.QTextListFormat ,和 PySide.QtGui.QTextTableFormat are usually more useful, and describe the formatting that is applied to specific parts of the document.

    A format has a FormatType which specifies the kinds of text item it can format; e.g. a block of text, a list, a table, etc. A format also has various properties (some specific to particular format types), as described by the Property enum. Every property has a corresponding Property.

    The format type is given by PySide.QtGui.QTextFormat.type() , and the format can be tested with PySide.QtGui.QTextFormat.isCharFormat() , PySide.QtGui.QTextFormat.isBlockFormat() , PySide.QtGui.QTextFormat.isListFormat() , PySide.QtGui.QTextFormat.isTableFormat() , PySide.QtGui.QTextFormat.isFrameFormat() ,和 PySide.QtGui.QTextFormat.isImageFormat() . If the type is determined, it can be retrieved with PySide.QtGui.QTextFormat.toCharFormat() , PySide.QtGui.QTextFormat.toBlockFormat() , PySide.QtGui.QTextFormat.toListFormat() , PySide.QtGui.QTextFormat.toTableFormat() , PySide.QtGui.QTextFormat.toFrameFormat() ,和 PySide.QtGui.QTextFormat.toImageFormat() .

    A format's properties can be set with the PySide.QtGui.QTextFormat.setProperty() functions, and retrieved with PySide.QtGui.QTextFormat.boolProperty() , PySide.QtGui.QTextFormat.intProperty() , PySide.QtGui.QTextFormat.doubleProperty() ,和 PySide.QtGui.QTextFormat.stringProperty() as appropriate. All the property IDs used in the format can be retrieved with allPropertyIds(). One format can be merged into another using PySide.QtGui.QTextFormat.merge() .

    A format's object index can be set with PySide.QtGui.QTextFormat.setObjectIndex() , and retrieved with PySide.QtGui.QTextFormat.objectIndex() . These methods can be used to associate the format with a PySide.QtGui.QTextObject . It is used to represent lists, frames, and tables inside the document.

    另请参阅

    富文本处理

    class PySide.QtGui. QTextFormat
    class PySide.QtGui. QTextFormat ( rhs )
    class PySide.QtGui. QTextFormat ( type )
    参数:

    Creates a new text format with an InvalidFormat .

    另请参阅

    QTextFormat.FormatType

    Creates a new text format with the same attributes as the other text format.

    Creates a new text format of the given type .

    另请参阅

    QTextFormat.FormatType

    PySide.QtGui.QTextFormat. 特性

    This enum describes the different properties a format can have.

    常量 描述
    QTextFormat.ObjectIndex The index of the formatted object. See PySide.QtGui.QTextFormat.objectIndex() .

    Paragraph and character properties

    常量 描述
    QTextFormat.CssFloat How a frame is located relative to the surrounding text
    QTextFormat.LayoutDirection The layout direction of the text in the document ( Qt.LayoutDirection ).
    QTextFormat.OutlinePen  
    QTextFormat.ForegroundBrush  
    QTextFormat.BackgroundBrush  
    QTextFormat.BackgroundImageUrl  

    Paragraph properties

    常量 描述
    QTextFormat.BlockAlignment  
    QTextFormat.BlockTopMargin  
    QTextFormat.BlockBottomMargin  
    QTextFormat.BlockLeftMargin  
    QTextFormat.BlockRightMargin  
    QTextFormat.TextIndent  
    QTextFormat.TabPositions Specifies the tab positions. The tab positions are structs of QTextOption.Tab which are stored in a QList (internally, in a QList < PySide.QtCore.QVariant >).
    QTextFormat.BlockIndent  
    QTextFormat.LineHeight  
    QTextFormat.LineHeightType  
    QTextFormat.BlockNonBreakableLines  
    QTextFormat.BlockTrailingHorizontalRulerWidth The width of a horizontal ruler element.

    Character properties

    常量 描述
    QTextFormat.FontFamily  
    QTextFormat.FontPointSize  
    QTextFormat.FontPixelSize  
    QTextFormat.FontSizeAdjustment Specifies the change in size given to the fontsize already set using FontPointSize or FontPixelSize .
    QTextFormat.FontFixedPitch  
    QTextFormat.FontWeight  
    QTextFormat.FontItalic  
    QTextFormat.FontUnderline This property has been deprecated. 使用 QTextFormat.TextUnderlineStyle 代替。
    QTextFormat.FontOverline  
    QTextFormat.FontStrikeOut  
    QTextFormat.FontCapitalization Specifies the capitalization type that is to be applied to the text.
    QTextFormat.FontLetterSpacing Changes the default spacing between individual letters in the font. The value is specified in percentage, with 100 as the default value.
    QTextFormat.FontWordSpacing Changes the default spacing between individual words. A positive value increases the word spacing by the corresponding pixels; a negative value decreases the spacing.
    QTextFormat.FontStyleHint 相当于 QFont.StyleHint 特性
    QTextFormat.FontStyleStrategy 相当于 QFont.StyleStrategy 特性
    QTextFormat.FontKerning Specifies whether the font has kerning turned on.
    QTextFormat.FontHintingPreference Controls the use of hinting according to values of the QFont.HintingPreference 枚举。
    QTextFormat.TextUnderlineColor  
    QTextFormat.TextVerticalAlignment  
    QTextFormat.TextOutline  
    QTextFormat.TextUnderlineStyle  
    QTextFormat.TextToolTip Specifies the (optional) tool tip to be displayed for a fragment of text.
    QTextFormat.IsAnchor  
    QTextFormat.AnchorHref  
    QTextFormat.AnchorName  
    QTextFormat.ObjectType  

    List properties

    常量 描述
    QTextFormat.ListStyle Specifies the style used for the items in a list, described by values of the QTextListFormat.Style 枚举。
    QTextFormat.ListIndent Specifies the amount of indentation used for a list.
    QTextFormat.ListNumberPrefix Defines the text which is prepended to item numbers in numeric lists.
    QTextFormat.ListNumberSuffix Defines the text which is appended to item numbers in numeric lists.

    Table and frame properties

    常量 描述
    QTextFormat.FrameBorder  
    QTextFormat.FrameBorderBrush  
    QTextFormat.FrameBorderStyle QTextFrameFormat.BorderStyle 枚举。
    QTextFormat.FrameBottomMargin  
    QTextFormat.FrameHeight  
    QTextFormat.FrameLeftMargin  
    QTextFormat.FrameMargin  
    QTextFormat.FramePadding  
    QTextFormat.FrameRightMargin  
    QTextFormat.FrameTopMargin  
    QTextFormat.FrameWidth  
    QTextFormat.TableCellSpacing  
    QTextFormat.TableCellPadding  
    QTextFormat.TableColumns  
    QTextFormat.TableColumnWidthConstraints  
    QTextFormat.TableHeaderRowCount  

    Table cell properties

    常量 描述
    QTextFormat.TableCellRowSpan  
    QTextFormat.TableCellColumnSpan  
    QTextFormat.TableCellLeftPadding  
    QTextFormat.TableCellRightPadding  
    QTextFormat.TableCellTopPadding  
    QTextFormat.TableCellBottomPadding  

    Image properties

    常量 描述
    QTextFormat.ImageName  
    QTextFormat.ImageWidth  
    QTextFormat.ImageHeight  

    Selection properties

    常量 描述
    QTextFormat.FullWidthSelection When set on the characterFormat of a selection, the whole width of the text will be shown selected.

    Page break properties

    常量 描述
    QTextFormat.PageBreakPolicy Specifies how pages are broken. See the QTextFormat.PageBreakFlag 枚举。
    QTextFormat.UserProperty  
    PySide.QtGui.QTextFormat. FormatType

    This enum describes the text item a PySide.QtGui.QTextFormat object is formatting.

    常量 描述
    QTextFormat.InvalidFormat An invalid format as created by the default constructor
    QTextFormat.BlockFormat The object formats a text block
    QTextFormat.CharFormat The object formats a single character
    QTextFormat.ListFormat The object formats a list
    QTextFormat.TableFormat The object formats a table
    QTextFormat.FrameFormat The object formats a frame
    QTextFormat.UserFormat  
    PySide.QtGui.QTextFormat. ObjectTypes

    This enum describes what kind of PySide.QtGui.QTextObject this format is associated with.

    常量 描述
    QTextFormat.NoObject  
    QTextFormat.ImageObject  
    QTextFormat.TableObject  
    QTextFormat.TableCellObject  
    QTextFormat.UserObject The first object that can be used for application-specific purposes.
    PySide.QtGui.QTextFormat. PageBreakFlag

    This enum describes how page breaking is performed when printing. It maps to the corresponding css properties.

    常量 描述
    QTextFormat.PageBreak_Auto The page break is determined automatically depending on the available space on the current page
    QTextFormat.PageBreak_AlwaysBefore The page is always broken before the paragraph/table
    QTextFormat.PageBreak_AlwaysAfter A new page is always started after the paragraph/table
    PySide.QtGui.QTextFormat. background ( )
    返回类型: PySide.QtGui.QBrush

    Returns the brush used to paint the document's background.

    PySide.QtGui.QTextFormat. boolProperty ( propertyId )
    参数: propertyId PySide.QtCore.int
    返回类型: PySide.QtCore.bool

    Returns the value of the property specified by propertyId . If the property isn't of QTextFormat::Bool type, false is returned instead.

    PySide.QtGui.QTextFormat. brushProperty ( propertyId )
    参数: propertyId PySide.QtCore.int
    返回类型: PySide.QtGui.QBrush

    Returns the value of the property given by propertyId ; if the property isn't of QVariant.Brush type, Qt.NoBrush 被返回取而代之。

    PySide.QtGui.QTextFormat. clearBackground ( )

    Clears the brush used to paint the document's background. The default brush will be used.

    PySide.QtGui.QTextFormat. clearForeground ( )

    Clears the brush used to paint the document's foreground. The default brush will be used.

    PySide.QtGui.QTextFormat. clearProperty ( propertyId )
    参数: propertyId PySide.QtCore.int

    Clears the value of the property given by propertyId

    另请参阅

    QTextFormat.Property

    PySide.QtGui.QTextFormat. colorProperty ( propertyId )
    参数: propertyId PySide.QtCore.int
    返回类型: PySide.QtGui.QColor

    Returns the value of the property given by propertyId ; if the property isn't of QVariant.Color type, an invalid color is returned instead.

    PySide.QtGui.QTextFormat. doubleProperty ( propertyId )
    参数: propertyId PySide.QtCore.int
    返回类型: PySide.QtCore.qreal

    Returns the value of the property specified by propertyId . If the property isn't of QVariant.Double or QMetaType.Float type, 0 is returned instead.

    PySide.QtGui.QTextFormat. foreground ( )
    返回类型: PySide.QtGui.QBrush

    Returns the brush used to render foreground details, such as text, frame outlines, and table borders.

    PySide.QtGui.QTextFormat. hasProperty ( propertyId )
    参数: propertyId PySide.QtCore.int
    返回类型: PySide.QtCore.bool

    Returns true if the text format has a property with the given propertyId ;否则返回 false。

    另请参阅

    PySide.QtGui.QTextFormat.properties() QTextFormat.Property

    PySide.QtGui.QTextFormat. intProperty ( propertyId )
    参数: propertyId PySide.QtCore.int
    返回类型: PySide.QtCore.int

    Returns the value of the property specified by propertyId . If the property is not of QTextFormat::Integer type, 0 is returned instead.

    PySide.QtGui.QTextFormat. isBlockFormat ( )
    返回类型: PySide.QtCore.bool

    Returns true if this text format is a BlockFormat ;否则返回 false。

    PySide.QtGui.QTextFormat. isCharFormat ( )
    返回类型: PySide.QtCore.bool

    Returns true if this text format is a CharFormat ;否则返回 false。

    PySide.QtGui.QTextFormat. isFrameFormat ( )
    返回类型: PySide.QtCore.bool

    Returns true if this text format is a FrameFormat ;否则返回 false。

    PySide.QtGui.QTextFormat. isImageFormat ( )
    返回类型: PySide.QtCore.bool

    Returns true if this text format is an image format; otherwise returns false.

    PySide.QtGui.QTextFormat. isListFormat ( )
    返回类型: PySide.QtCore.bool

    Returns true if this text format is a ListFormat ;否则返回 false。

    PySide.QtGui.QTextFormat. isTableCellFormat ( )
    返回类型: PySide.QtCore.bool

    Returns true if this text format is a TableCellFormat ;否则返回 false。

    PySide.QtGui.QTextFormat. isTableFormat ( )
    返回类型: PySide.QtCore.bool

    Returns true if this text format is a TableFormat ;否则返回 false。

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

    Returns true if the format is valid (i.e. is not InvalidFormat ); otherwise returns false.

    PySide.QtGui.QTextFormat. layoutDirection ( )
    返回类型: PySide.QtCore.Qt.LayoutDirection

    Returns the document's layout direction.

    PySide.QtGui.QTextFormat. lengthProperty ( propertyId )
    参数: propertyId PySide.QtCore.int
    返回类型: PySide.QtGui.QTextLength

    Returns the value of the property given by propertyId .

    PySide.QtGui.QTextFormat. lengthVectorProperty ( propertyId )
    参数: propertyId PySide.QtCore.int
    返回类型:

    Returns the value of the property given by propertyId . If the property isn't of QTextFormat::LengthVector type, an empty length vector is returned instead.

    PySide.QtGui.QTextFormat. merge ( other )
    参数: other PySide.QtGui.QTextFormat

    Merges the other format with this format; where there are conflicts the other format takes precedence.

    PySide.QtGui.QTextFormat. objectIndex ( )
    返回类型: PySide.QtCore.int

    Returns the index of the format object, or -1 if the format object is invalid.

    PySide.QtGui.QTextFormat. objectType ( )
    返回类型: PySide.QtCore.int

    Returns the text format's object type.

    另请参阅

    QTextFormat.ObjectTypes PySide.QtGui.QTextFormat.setObjectType()

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

    Returns true if this text format is different from the other text format.

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

    Returns true if this text format is the same as the other text format.

    PySide.QtGui.QTextFormat. penProperty ( propertyId )
    参数: propertyId PySide.QtCore.int
    返回类型: PySide.QtGui.QPen

    Returns the value of the property given by propertyId ; if the property isn't of QVariant.Pen type, Qt.NoPen 被返回取而代之。

    PySide.QtGui.QTextFormat. properties ( )
    返回类型:

    Returns a map with all properties of this text format.

    PySide.QtGui.QTextFormat. 特性 ( propertyId )
    参数: propertyId PySide.QtCore.int
    返回类型: object

    Returns the property specified by the given propertyId .

    另请参阅

    PySide.QtGui.QTextFormat.setProperty() QTextFormat.Property

    PySide.QtGui.QTextFormat. propertyCount ( )
    返回类型: PySide.QtCore.int

    Returns the number of properties stored in the format.

    PySide.QtGui.QTextFormat. setBackground ( brush )
    参数: brush PySide.QtGui.QBrush

    Sets the brush use to paint the document's background to the brush 指定。

    PySide.QtGui.QTextFormat. setForeground ( brush )
    参数: brush PySide.QtGui.QBrush

    Sets the foreground brush to the specified brush . The foreground brush is mostly used to render text.

    PySide.QtGui.QTextFormat. setLayoutDirection ( direction )
    参数: direction PySide.QtCore.Qt.LayoutDirection
    PySide.QtGui.QTextFormat. setObjectIndex ( object )
    参数: object PySide.QtCore.int

    Sets the format object's object index .

    PySide.QtGui.QTextFormat. setObjectType ( type )
    参数: type PySide.QtCore.int

    Sets the text format's object type to type .

    另请参阅

    QTextFormat.ObjectTypes PySide.QtGui.QTextFormat.objectType()

    PySide.QtGui.QTextFormat. setProperty ( propertyId , value )
    参数:
    • propertyId PySide.QtCore.int
    • value – object

    Sets the property specified by the propertyId 到给定 value .

    另请参阅

    PySide.QtGui.QTextFormat.property() QTextFormat.Property

    PySide.QtGui.QTextFormat. setProperty ( propertyId , lengths )
    参数:
    • propertyId PySide.QtCore.int
    • lengths
    PySide.QtGui.QTextFormat. stringProperty ( propertyId )
    参数: propertyId PySide.QtCore.int
    返回类型: unicode

    Returns the value of the property given by propertyId ; if the property isn't of QVariant.String type, an empty string is returned instead.

    PySide.QtGui.QTextFormat. toBlockFormat ( )
    返回类型: PySide.QtGui.QTextBlockFormat

    Returns this format as a block format.

    PySide.QtGui.QTextFormat. toCharFormat ( )
    返回类型: PySide.QtGui.QTextCharFormat

    Returns this format as a character format.

    PySide.QtGui.QTextFormat. toFrameFormat ( )
    返回类型: PySide.QtGui.QTextFrameFormat

    Returns this format as a frame format.

    PySide.QtGui.QTextFormat. toImageFormat ( )
    返回类型: PySide.QtGui.QTextImageFormat

    Returns this format as an image format.

    PySide.QtGui.QTextFormat. toListFormat ( )
    返回类型: PySide.QtGui.QTextListFormat

    Returns this format as a list format.

    PySide.QtGui.QTextFormat. toTableCellFormat ( )
    返回类型: PySide.QtGui.QTextTableCellFormat

    Returns this format as a table cell format.

    PySide.QtGui.QTextFormat. toTableFormat ( )
    返回类型: PySide.QtGui.QTextTableFormat

    Returns this format as a table format.

    PySide.QtGui.QTextFormat. type ( )
    返回类型: PySide.QtCore.int

    Returns the type of this format.

    另请参阅

    QTextFormat.FormatType