The QTextCharFormat class provides formatting information for characters in a QTextDocument . 更多...
继承 QTextFormat .
Inherited by QTextImageFormat and QTextTableCellFormat .
The QTextCharFormat class provides formatting information for characters in a 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 setFont () function, and each aspect of its appearance can be adjusted to give the desired 效果。 setFontFamily () 和 setFontPointSize () define the font's family (e.g. Times) and printed size; setFontWeight () 和 setFontItalic () provide control over the style of the font. setFontUnderline (), setFontOverline (), setFontStrikeOut (),和 setFontFixedPitch () provide additional effects for text.
The color is set with setForeground (). If the text is intended to be used as an anchor (for hyperlinks), this can be enabled with setAnchor ()。 setAnchorHref () 和 setAnchorNames () functions are used to specify the information about the hyperlink's destination and the anchor's name.
This enum describes the different ways drawing underlined text.
| 常量 | 值 | 描述 |
|---|---|---|
| QTextCharFormat.NoUnderline | 0 | Text is draw without any underlining decoration. |
| QTextCharFormat.SingleUnderline | 1 | A line is drawn using Qt.SolidLine . |
| QTextCharFormat.DashUnderline | 2 | Dashes are drawn using Qt.DashLine . |
| QTextCharFormat.DotLine | 3 | Dots are drawn using Qt.DotLine ; |
| QTextCharFormat.DashDotLine | 4 | Dashs and dots are drawn using Qt.DashDotLine . |
| QTextCharFormat.DashDotDotLine | 5 | Underlines draw drawn using Qt.DashDotDotLine . |
| QTextCharFormat.WaveUnderline | 6 | The text is underlined using a wave shaped line. |
| QTextCharFormat.SpellCheckUnderline | 7 | The underline is drawn depending on the QStyle.SH_SpellCeckUnderlineStyle style hint of the QApplication style. By default this is mapped to WaveUnderline, on Mac OS X it is mapped to DashDotLine. |
另请参阅 Qt.PenStyle .
This enum describes the ways that adjacent characters can be vertically aligned.
| 常量 | 值 | 描述 |
|---|---|---|
| QTextCharFormat.AlignNormal | 0 | Adjacent characters are positioned in the standard way for text in the writing system in use. |
| QTextCharFormat.AlignSuperScript | 1 | Characters are placed above the base line for normal text. |
| QTextCharFormat.AlignSubScript | 2 | Characters are placed below the base line for normal text. |
| QTextCharFormat.AlignMiddle | 3 | The center of the object is vertically aligned with the base line. Currently, this is only implemented for inline 对象。 |
| QTextCharFormat.AlignBottom | 5 | The bottom edge of the object is vertically aligned with the base line. |
| QTextCharFormat.AlignTop | 4 | The top edge of the object is vertically aligned with the base line. |
| QTextCharFormat.AlignBaseline | 6 | The base lines of the characters are aligned. |
Constructs a new character format object.
Returns the text format's hypertext link, or an empty string if none has been set.
另请参阅 setAnchorHref ().
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.
该函数在 Qt 4.3 引入。
另请参阅 setAnchorNames ().
Returns the font for this character format.
另请参阅 setFont ().
Returns the current capitalization type of the font.
该函数在 Qt 4.4 引入。
另请参阅 setFontCapitalization ().
Returns the text format's font family.
另请参阅 setFontFamily () 和 font ().
Returns true if the text format's font is fixed pitch; otherwise returns false.
另请参阅 setFontFixedPitch () and font ().
Returns the hinting preference set for this text format.
该函数在 Qt 4.8 引入。
另请参阅 setFontHintingPreference (), font (),和 QFont.hintingPreference ().
Returns true if the text format's font is italic; otherwise returns false.
另请参阅 setFontItalic () 和 font ().
Returns true if the font kerning is enabled.
该函数在 Qt 4.5 引入。
另请参阅 setFontKerning () 和 font ().
Returns the current letter spacing percentage.
该函数在 Qt 4.4 引入。
另请参阅 setFontLetterSpacing ().
Returns true if the text format's font is overlined; otherwise returns false.
另请参阅 setFontOverline () 和 font ().
Returns the font size used to display text in this format.
另请参阅 setFontPointSize () 和 font ().
Returns true if the text format's font is struck out (has a horizontal line drawn through it); otherwise returns false.
另请参阅 setFontStrikeOut () 和 font ().
Returns the font style hint.
该函数在 Qt 4.5 引入。
另请参阅 setFontStyleHint () 和 font ().
Returns the current font style strategy.
该函数在 Qt 4.5 引入。
另请参阅 setFontStyleStrategy () and font ().
Returns true if the text format's font is underlined; otherwise returns false.
另请参阅 setFontUnderline () 和 font ().
Returns the text format's font weight.
另请参阅 setFontWeight (), font (),和 QFont.Weight .
Returns the current word spacing value.
该函数在 Qt 4.4 引入。
另请参阅 setFontWordSpacing ().
Returns true if the text is formatted as an anchor; otherwise returns false.
另请参阅 setAnchor (), setAnchorHref (),和 setAnchorNames ().
Returns true if this character format is valid; otherwise returns false.
若 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 setAnchorHref (),和 optionally setAnchorNames () 到 create a hypertext link.
另请参阅 isAnchor ().
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 setAnchorNames ().
To format the text as a hypertext link use setAnchor ().
另请参阅 anchorHref ().
Sets the text format's anchor names . For the anchor to work as a hyperlink, the destination must be set with setAnchorHref () 和 anchor must be enabled with setAnchor ().
该函数在 Qt 4.3 引入。
另请参阅 anchorNames ().
Sets the text format's font .
另请参阅 font ().
Sets the capitalization of the text that apppears in this font to capitalization .
A font's capitalization makes the text appear in the selected capitalization mode.
该函数在 Qt 4.4 引入。
另请参阅 fontCapitalization ().
Sets the text format's font family .
另请参阅 fontFamily () 和 setFont ().
若 fixedPitch is true, sets the text format's font to be fixed pitch; otherwise a non-fixed pitch font is used.
另请参阅 fontFixedPitch () 和 setFont ().
Sets the hinting preference of the text format's font to be hintingPreference .
该函数在 Qt 4.8 引入。
另请参阅 fontHintingPreference (), setFont (),和 QFont.setHintingPreference ().
若 italic is true, sets the text format's font to be italic; otherwise the font will be non-italic.
另请参阅 fontItalic () 和 setFont ().
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.
该函数在 Qt 4.5 引入。
另请参阅 fontKerning () 和 setFont ().
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.
该函数在 Qt 4.4 引入。
另请参阅 fontLetterSpacing ().
若 overline is true, sets the text format's font to be overlined; otherwise the font is displayed non-overlined.
另请参阅 fontOverline () 和 setFont ().
Sets the text format's font size .
另请参阅 fontPointSize () 和 setFont ().
若 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.
另请参阅 fontStrikeOut () 和 setFont ().
Sets the font style hint and strategy .
Qt does not support style hints on X11 since this information is not provided by the window system.
该函数在 Qt 4.5 引入。
另请参阅 fontStyleHint (), setFont (),和 QFont.setStyleHint ().
Sets the font style strategy .
该函数在 Qt 4.5 引入。
另请参阅 fontStyleStrategy (), setFont (),和 QFont.setStyleStrategy ().
若 underline is true, sets the text format's font to be underlined; otherwise it is displayed non-underlined.
另请参阅 fontUnderline () 和 setFont ().
Sets the text format's font weight to weight .
另请参阅 fontWeight (), setFont (),和 QFont.Weight .
Sets the word spacing of this format to the given spacing , in pixels.
该函数在 Qt 4.4 引入。
另请参阅 fontWordSpacing ().
Sets the pen used to draw the outlines of characters to the given pen .
另请参阅 textOutline ().
Sets the tool tip for a fragment of text to the given text .
该函数在 Qt 4.3 引入。
另请参阅 toolTip ().
Sets the underline color used for the characters with this format to the color 指定。
另请参阅 underlineColor ().
Sets the style of underlining the text to style .
该函数在 Qt 4.2 引入。
另请参阅 underlineStyle ().
Sets the vertical alignment used for the characters with this format to the alignment 指定。
另请参阅 verticalAlignment ().
Returns the pen used to draw the outlines of characters in this format.
另请参阅 setTextOutline ().
Returns the tool tip that is displayed for a fragment of text.
该函数在 Qt 4.3 引入。
另请参阅 setToolTip ().
Returns the color used to underline the characters with this format.
另请参阅 setUnderlineColor ().
Returns the style of underlining the text.
该函数在 Qt 4.2 引入。
另请参阅 setUnderlineStyle ().
Returns the vertical alignment used for characters with this format.
另请参阅 setVerticalAlignment ().