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

    上一话题

    QFont

    下一话题

    QTextTableCellFormat

    QTextCharFormat

    继承者: QTextTableCellFormat , QTextImageFormat

    详细描述

    PySide.QtGui.QTextCharFormat class provides formatting information for characters in a PySide.QtGui.QTextDocument .

    The character format of text in a document specifies the visual properties of the text, as well as information about its role in a hypertext document.

    The font used can be set by supplying a font to the PySide.QtGui.QTextCharFormat.setFont() function, and each aspect of its appearance can be adjusted to give the desired effect. PySide.QtGui.QTextCharFormat.setFontFamily() and PySide.QtGui.QTextCharFormat.setFontPointSize() define the font's family (e.g. Times) and printed size; PySide.QtGui.QTextCharFormat.setFontWeight() and PySide.QtGui.QTextCharFormat.setFontItalic() provide control over the style of the font. PySide.QtGui.QTextCharFormat.setFontUnderline() , PySide.QtGui.QTextCharFormat.setFontOverline() , PySide.QtGui.QTextCharFormat.setFontStrikeOut() ,和 PySide.QtGui.QTextCharFormat.setFontFixedPitch() provide additional effects for text.

    The color is set with PySide.QtGui.QTextFormat.setForeground() . If the text is intended to be used as an anchor (for hyperlinks), this can be enabled with PySide.QtGui.QTextCharFormat.setAnchor() PySide.QtGui.QTextCharFormat.setAnchorHref() and PySide.QtGui.QTextCharFormat.setAnchorNames() functions are used to specify the information about the hyperlink's destination and the anchor's name.

    class PySide.QtGui. QTextCharFormat
    class PySide.QtGui. QTextCharFormat ( QTextCharFormat )
    class PySide.QtGui. QTextCharFormat ( fmt )
    参数:

    Constructs a new character format object.

    Creates a new character format with the same attributes as the given text format.

    PySide.QtGui.QTextCharFormat. VerticalAlignment

    This enum describes the ways that adjacent characters can be vertically aligned.

    常量 描述
    QTextCharFormat.AlignNormal Adjacent characters are positioned in the standard way for text in the writing system in use.
    QTextCharFormat.AlignSuperScript Characters are placed above the base line for normal text.
    QTextCharFormat.AlignSubScript Characters are placed below the base line for normal text.
    QTextCharFormat.AlignMiddle The center of the object is vertically aligned with the base line. Currently, this is only implemented for inline objects.
    QTextCharFormat.AlignBottom The bottom edge of the object is vertically aligned with the base line.
    QTextCharFormat.AlignTop The top edge of the object is vertically aligned with the base line.
    QTextCharFormat.AlignBaseline The base lines of the characters are aligned.
    PySide.QtGui.QTextCharFormat. UnderlineStyle

    This enum describes the different ways drawing underlined text.

    常量 描述
    QTextCharFormat.NoUnderline Text is draw without any underlining decoration.
    QTextCharFormat.SingleUnderline A line is drawn using Qt.SolidLine .
    QTextCharFormat.DashUnderline Dashes are drawn using Qt.DashLine .
    QTextCharFormat.DotLine Dots are drawn using Qt.DotLine ;
    QTextCharFormat.DashDotLine Dashs and dots are drawn using Qt.DashDotLine .
    QTextCharFormat.DashDotDotLine Underlines draw drawn using Qt.DashDotDotLine .
    QTextCharFormat.WaveUnderline The text is underlined using a wave shaped line.
    QTextCharFormat.SpellCheckUnderline The underline is drawn depending on the QStyle::SH_SpellCeckUnderlineStyle style hint of the PySide.QtGui.QApplication style. By default this is mapped to WaveUnderline , on Mac OS X it is mapped to DashDotLine .

    另请参阅

    Qt.PenStyle

    PySide.QtGui.QTextCharFormat. anchorHref ( )
    返回类型: unicode

    Returns the text format's hypertext link, or an empty string if none has been set.

    PySide.QtGui.QTextCharFormat. anchorNames ( )
    返回类型: 字符串列表

    Returns the anchor names associated with this text format, or an empty string list if none has been set. If the anchor names are set, text with this format can be the destination of a hypertext link.

    PySide.QtGui.QTextCharFormat. font ( )
    返回类型: PySide.QtGui.QFont

    Returns the font for this character format.

    PySide.QtGui.QTextCharFormat. fontCapitalization ( )
    返回类型: PySide.QtGui.QFont.Capitalization

    Returns the current capitalization type of the font.

    PySide.QtGui.QTextCharFormat. fontFamily ( )
    返回类型: unicode

    Returns the text format's font family.

    PySide.QtGui.QTextCharFormat. fontFixedPitch ( )
    返回类型: PySide.QtCore.bool

    Returns true if the text format's font is fixed pitch; otherwise returns false.

    PySide.QtGui.QTextCharFormat. fontHintingPreference ( )
    返回类型: PySide.QtGui.QFont.HintingPreference

    Returns the hinting preference set for this text format.

    PySide.QtGui.QTextCharFormat. fontItalic ( )
    返回类型: PySide.QtCore.bool

    Returns true if the text format's font is italic; otherwise returns false.

    PySide.QtGui.QTextCharFormat. fontKerning ( )
    返回类型: PySide.QtCore.bool

    Returns true if the font kerning is enabled.

    PySide.QtGui.QTextCharFormat. fontLetterSpacing ( )
    返回类型: PySide.QtCore.qreal

    Returns the current letter spacing percentage.

    PySide.QtGui.QTextCharFormat. fontOverline ( )
    返回类型: PySide.QtCore.bool

    Returns true if the text format's font is overlined; otherwise returns false.

    PySide.QtGui.QTextCharFormat. fontPointSize ( )
    返回类型: PySide.QtCore.qreal

    Returns the font size used to display text in this format.

    PySide.QtGui.QTextCharFormat. fontStrikeOut ( )
    返回类型: PySide.QtCore.bool

    Returns true if the text format's font is struck out (has a horizontal line drawn through it); otherwise returns false.

    PySide.QtGui.QTextCharFormat. fontStyleHint ( )
    返回类型: PySide.QtGui.QFont.StyleHint

    Returns the font style hint.

    PySide.QtGui.QTextCharFormat. fontStyleStrategy ( )
    返回类型: PySide.QtGui.QFont.StyleStrategy

    Returns the current font style strategy.

    PySide.QtGui.QTextCharFormat. fontUnderline ( )
    返回类型: PySide.QtCore.bool

    Returns true if the text format's font is underlined; otherwise returns false.

    PySide.QtGui.QTextCharFormat. fontWeight ( )
    返回类型: PySide.QtCore.int

    Returns the text format's font weight.

    PySide.QtGui.QTextCharFormat. fontWordSpacing ( )
    返回类型: PySide.QtCore.qreal

    Returns the current word spacing value.

    PySide.QtGui.QTextCharFormat. isAnchor ( )
    返回类型: PySide.QtCore.bool

    Returns true if the text is formatted as an anchor; otherwise returns false.

    PySide.QtGui.QTextCharFormat. setAnchor ( anchor )
    参数: anchor PySide.QtCore.bool

    anchor is true, text with this format represents an anchor, and is formatted in the appropriate way; otherwise the text is formatted normally. (Anchors are hyperlinks which are often shown underlined and in a different color from plain text.)

    The way the text is rendered is independent of whether or not the format has a valid anchor defined. Use PySide.QtGui.QTextCharFormat.setAnchorHref() , and optionally PySide.QtGui.QTextCharFormat.setAnchorNames() to create a hypertext link.

    PySide.QtGui.QTextCharFormat. setAnchorHref ( value )
    参数: value – unicode

    Sets the hypertext link for the text format to the given value . This is typically a URL like “ http://example.com/index.html ”.

    The anchor will be displayed with the value as its display text; if you want to display different text call PySide.QtGui.QTextCharFormat.setAnchorNames() .

    To format the text as a hypertext link use PySide.QtGui.QTextCharFormat.setAnchor() .

    PySide.QtGui.QTextCharFormat. setAnchorNames ( names )
    参数: names – list of strings

    Sets the text format's anchor names . For the anchor to work as a hyperlink, the destination must be set with PySide.QtGui.QTextCharFormat.setAnchorHref() and the anchor must be enabled with PySide.QtGui.QTextCharFormat.setAnchor() .

    PySide.QtGui.QTextCharFormat. setFont ( font )
    参数: font PySide.QtGui.QFont

    Sets the text format's font .

    PySide.QtGui.QTextCharFormat. setFontCapitalization ( capitalization )
    参数: capitalization PySide.QtGui.QFont.Capitalization
    PySide.QtGui.QTextCharFormat. setFontFamily ( family )
    参数: family – unicode

    Sets the text format's font family .

    PySide.QtGui.QTextCharFormat. setFontFixedPitch ( fixedPitch )
    参数: fixedPitch PySide.QtCore.bool

    fixedPitch is true, sets the text format's font to be fixed pitch; otherwise a non-fixed pitch font is used.

    PySide.QtGui.QTextCharFormat. setFontHintingPreference ( hintingPreference )
    参数: hintingPreference PySide.QtGui.QFont.HintingPreference
    PySide.QtGui.QTextCharFormat. setFontItalic ( italic )
    参数: italic PySide.QtCore.bool

    italic is true, sets the text format's font to be italic; otherwise the font will be non-italic.

    PySide.QtGui.QTextCharFormat. setFontKerning ( enable )
    参数: enable PySide.QtCore.bool

    Enables kerning for this font if enable is true; otherwise disables it.

    When kerning is enabled, glyph metrics do not add up anymore, even for Latin text. In other words, the assumption that width(‘a') + width(‘b') is equal to width(“ab”) is not neccesairly true.

    PySide.QtGui.QTextCharFormat. setFontLetterSpacing ( spacing )
    参数: spacing PySide.QtCore.qreal

    Sets the letter spacing of this format to the given spacing , in percent. A value of 100 indicates default spacing; a value of 200 doubles the amount of space a letter takes.

    PySide.QtGui.QTextCharFormat. setFontOverline ( overline )
    参数: overline PySide.QtCore.bool

    overline is true, sets the text format's font to be overlined; otherwise the font is displayed non-overlined.

    PySide.QtGui.QTextCharFormat. setFontPointSize ( size )
    参数: size PySide.QtCore.qreal

    Sets the text format's font size .

    PySide.QtGui.QTextCharFormat. setFontStrikeOut ( strikeOut )
    参数: strikeOut PySide.QtCore.bool

    strikeOut is true, sets the text format's font with strike-out enabled (with a horizontal line through it); otherwise it is displayed without strikeout.

    PySide.QtGui.QTextCharFormat. setFontStyleHint ( hint [ , strategy=QFont.PreferDefault ] )
    参数:
    PySide.QtGui.QTextCharFormat. setFontStyleStrategy ( strategy )
    参数: strategy PySide.QtGui.QFont.StyleStrategy
    PySide.QtGui.QTextCharFormat. setFontUnderline ( underline )
    参数: underline PySide.QtCore.bool

    underline is true, sets the text format's font to be underlined; otherwise it is displayed non-underlined.

    PySide.QtGui.QTextCharFormat. setFontWeight ( weight )
    参数: weight PySide.QtCore.int

    Sets the text format's font weight to weight .

    PySide.QtGui.QTextCharFormat. setFontWordSpacing ( spacing )
    参数: spacing PySide.QtCore.qreal

    Sets the word spacing of this format to the given spacing , in pixels.

    PySide.QtGui.QTextCharFormat. setTableCellColumnSpan ( tableCellColumnSpan )
    参数: tableCellColumnSpan PySide.QtCore.int

    If this character format is applied to characters in a table cell, the cell will span tableCellColumnSpan columns.

    PySide.QtGui.QTextCharFormat. setTableCellRowSpan ( tableCellRowSpan )
    参数: tableCellRowSpan PySide.QtCore.int

    If this character format is applied to characters in a table cell, the cell will span tableCellRowSpan rows.

    PySide.QtGui.QTextCharFormat. setTextOutline ( pen )
    参数: pen PySide.QtGui.QPen

    Sets the pen used to draw the outlines of characters to the given pen .

    PySide.QtGui.QTextCharFormat. setToolTip ( tip )
    参数: tip – unicode

    Sets the tool tip for a fragment of text to the given text .

    PySide.QtGui.QTextCharFormat. setUnderlineColor ( color )
    参数: color PySide.QtGui.QColor

    Sets the underline color used for the characters with this format to the color 指定。

    PySide.QtGui.QTextCharFormat. setUnderlineStyle ( style )
    参数: style PySide.QtGui.QTextCharFormat.UnderlineStyle

    Sets the style of underlining the text to style .

    PySide.QtGui.QTextCharFormat. setVerticalAlignment ( alignment )
    参数: alignment PySide.QtGui.QTextCharFormat.VerticalAlignment

    Sets the vertical alignment used for the characters with this format to the alignment 指定。

    PySide.QtGui.QTextCharFormat. tableCellColumnSpan ( )
    返回类型: PySide.QtCore.int

    If this character format is applied to characters in a table cell, this function returns the number of columns spanned by the text (this may be 1); otherwise it returns 1.

    PySide.QtGui.QTextCharFormat. tableCellRowSpan ( )
    返回类型: PySide.QtCore.int

    If this character format is applied to characters in a table cell, this function returns the number of rows spanned by the text (this may be 1); otherwise it returns 1.

    PySide.QtGui.QTextCharFormat. textOutline ( )
    返回类型: PySide.QtGui.QPen

    Returns the pen used to draw the outlines of characters in this format.

    PySide.QtGui.QTextCharFormat. toolTip ( )
    返回类型: unicode

    Returns the tool tip that is displayed for a fragment of text.

    PySide.QtGui.QTextCharFormat. underlineColor ( )
    返回类型: PySide.QtGui.QColor

    Returns the color used to underline the characters with this format.

    PySide.QtGui.QTextCharFormat. underlineStyle ( )
    返回类型: PySide.QtGui.QTextCharFormat.UnderlineStyle

    Returns the style of underlining the text.

    PySide.QtGui.QTextCharFormat. verticalAlignment ( )
    返回类型: PySide.QtGui.QTextCharFormat.VerticalAlignment

    Returns the vertical alignment used for characters with this format.