QtBase
v6.3.1
|
The QTextCharFormat class provides formatting information for characters in a QTextDocument. \inmodule QtGui. More...
#include <qtextformat.h>
Protected Member Functions | |
QTextCharFormat (const QTextFormat &fmt) | |
Friends | |
class | QTextFormat |
Q_GUI_EXPORT QDataStream & | operator<< (QDataStream &, const QTextCharFormat &) |
Q_GUI_EXPORT QDataStream & | operator>> (QDataStream &, QTextCharFormat &) |
The QTextCharFormat class provides formatting information for characters in a QTextDocument. \inmodule QtGui.
\reentrant
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 effect. setFontFamilies() and setFontPointSize() define the font's family (e.g. Times) and printed size; setFontWeight() and setFontItalic() provide control over the style of the font. setFontUnderline(), setFontOverline(), setFontStrikeOut(), and 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(). The setAnchorHref() and setAnchorNames() functions are used to specify the information about the hyperlink's destination and the anchor's name.
Definition at line 415 of file qtextformat.h.
This enum specifies how the setFont() function should behave with respect to unset font properties.
\value FontPropertiesSpecifiedOnly If a property is not explicitly set, do not change the text format's property value. \value FontPropertiesAll If a property is not explicitly set, override the text format's property with a default value.
Enumerator | |
---|---|
FontPropertiesSpecifiedOnly | |
FontPropertiesAll |
Definition at line 442 of file qtextformat.h.
This enum describes the different ways drawing underlined text.
\value NoUnderline Text is draw without any underlining decoration. \value SingleUnderline A line is drawn using Qt::SolidLine. \value DashUnderline Dashes are drawn using Qt::DashLine. \value DotLine Dots are drawn using Qt::DotLine; \value DashDotLine Dashes and dots are drawn using Qt::DashDotLine. \value DashDotDotLine Underlines draw drawn using Qt::DashDotDotLine. \value WaveUnderline The text is underlined using a wave shaped line. \value SpellCheckUnderline The underline is drawn depending on the SpellCheckUnderlineStyle theme hint of QPlatformTheme. By default this is mapped to WaveUnderline, on \macos it is mapped to DotLine.
Enumerator | |
---|---|
NoUnderline | |
SingleUnderline | |
DashUnderline | |
DotLine | |
DashDotLine | |
DashDotDotLine | |
WaveUnderline | |
SpellCheckUnderline |
Definition at line 427 of file qtextformat.h.
This enum describes the ways that adjacent characters can be vertically aligned.
\value AlignNormal Adjacent characters are positioned in the standard way for text in the writing system in use. \value AlignSuperScript Characters are placed above the base line for normal text. \value AlignSubScript Characters are placed below the base line for normal text. \value AlignMiddle The center of the object is vertically aligned with the base line. Currently, this is only implemented for inline objects. \value AlignBottom The bottom edge of the object is vertically aligned with the base line. \value AlignTop The top edge of the object is vertically aligned with the base line. \value AlignBaseline The base lines of the characters are aligned.
Enumerator | |
---|---|
AlignNormal | |
AlignSuperScript | |
AlignSubScript | |
AlignMiddle | |
AlignTop | |
AlignBottom | |
AlignBaseline |
Definition at line 418 of file qtextformat.h.
QTextCharFormat::QTextCharFormat | ( | ) |
Constructs a new character format object.
Definition at line 1486 of file qtextformat.cpp.
|
explicitprotected |
Definition at line 1495 of file qtextformat.cpp.
|
inline |
Returns the text format's hypertext link, or an empty string if none has been set.
Definition at line 600 of file qtextformat.h.
QStringList QTextCharFormat::anchorNames | ( | ) | const |
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.
Definition at line 2017 of file qtextformat.cpp.
|
inline |
Returns the the baseline offset in %.
Definition at line 590 of file qtextformat.h.
QFont QTextCharFormat::font | ( | ) | const |
Returns the font for this character format.
Definition at line 2183 of file qtextformat.cpp.
|
inline |
Returns the current capitalization type of the font.
Definition at line 491 of file qtextformat.h.
|
inline |
Definition at line 462 of file qtextformat.h.
|
inline |
Returns true
if the text format's font is fixed pitch; otherwise returns false
.
Definition at line 527 of file qtextformat.h.
|
inline |
Returns the hinting preference set for this text format.
Definition at line 549 of file qtextformat.h.
|
inline |
Returns true
if the text format's font is italic; otherwise returns false
.
Definition at line 487 of file qtextformat.h.
|
inline |
Returns true
if the font kerning is enabled.
Definition at line 556 of file qtextformat.h.
|
inline |
Returns the current letter spacing.
Definition at line 499 of file qtextformat.h.
|
inline |
Returns the letter spacing type of this format..
Definition at line 495 of file qtextformat.h.
|
inline |
Returns true
if the text format's font is overlined; otherwise returns false
.
Definition at line 512 of file qtextformat.h.
|
inline |
Returns the font size used to display text in this format.
Definition at line 478 of file qtextformat.h.
|
inline |
Returns the current font stretching.
Definition at line 532 of file qtextformat.h.
|
inline |
Returns true
if the text format's font is struck out (has a horizontal line drawn through it); otherwise returns false
.
Definition at line 517 of file qtextformat.h.
|
inline |
Returns the font style hint.
Definition at line 539 of file qtextformat.h.
|
inline |
Definition at line 472 of file qtextformat.h.
|
inline |
Returns the current font style strategy.
Definition at line 541 of file qtextformat.h.
bool QTextCharFormat::fontUnderline | ( | ) | const |
Returns true
if the text format's font is underlined; otherwise returns false
.
Definition at line 1667 of file qtextformat.cpp.
|
inline |
Returns the text format's font weight.
Definition at line 483 of file qtextformat.h.
|
inline |
Returns the current word spacing value.
Definition at line 503 of file qtextformat.h.
|
inline |
Returns true
if the text is formatted as an anchor; otherwise returns false
.
Definition at line 595 of file qtextformat.h.
|
inline |
Returns true
if this character format is valid; otherwise returns false.
Definition at line 440 of file qtextformat.h.
|
inline |
If 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(), and optionally setAnchorNames() to create a hypertext link.
Definition at line 593 of file qtextformat.h.
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().
Definition at line 598 of file qtextformat.h.
|
inline |
Sets the text format's anchor names. For the anchor to work as a hyperlink, the destination must be set with setAnchorHref() and the anchor must be enabled with setAnchor().
Definition at line 603 of file qtextformat.h.
Sets the base line (in % of height) of text to baseline. A positive value moves the text up, by the corresponding %; a negative value moves it down. The default value is 0.
Definition at line 588 of file qtextformat.h.
void QTextCharFormat::setFont | ( | const QFont & | font, |
FontPropertiesInheritanceBehavior | behavior = FontPropertiesAll |
||
) |
Sets the text format's font.
If behavior is QTextCharFormat::FontPropertiesAll, the font property that has not been explicitly set is treated like as it were set with default value; If behavior is QTextCharFormat::FontPropertiesSpecifiedOnly, the font property that has not been explicitly set is ignored and the respective property value remains unchanged.
Definition at line 2127 of file qtextformat.cpp.
|
inline |
Sets the capitalization of the text that appears in this font to capitalization.
A font's capitalization makes the text appear in the selected capitalization mode.
Definition at line 489 of file qtextformat.h.
|
inline |
Sets the text format's font families.
Definition at line 456 of file qtextformat.h.
|
inline |
If fixedPitch is true, sets the text format's font to be fixed pitch; otherwise a non-fixed pitch font is used.
Definition at line 525 of file qtextformat.h.
|
inline |
Sets the hinting preference of the text format's font to be hintingPreference.
Definition at line 544 of file qtextformat.h.
|
inline |
If italic is true, sets the text format's font to be italic; otherwise the font will be non-italic.
Definition at line 485 of file qtextformat.h.
|
inline |
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.
Definition at line 554 of file qtextformat.h.
Sets the letter spacing of this format to the given spacing. The meaning of the value depends on the font letter spacing type.
For percentage spacing a value of 100 indicates default spacing; a value of 200 doubles the amount of space a letter takes.
Definition at line 497 of file qtextformat.h.
|
inline |
Sets the letter spacing type of this format to letterSpacingType.
Definition at line 493 of file qtextformat.h.
|
inline |
If overline is true, sets the text format's font to be overlined; otherwise the font is displayed non-overlined.
Definition at line 510 of file qtextformat.h.
Sets the text format's font size.
Definition at line 476 of file qtextformat.h.
|
inline |
Sets the stretch factor for the font to factor.
The stretch factor changes the width of all characters in the font by factor percent. For example, setting factor to 150 results in all characters in the font being 1.5 times (ie. 150%) wider. The default stretch factor is 100. The minimum stretch factor is 1, and the maximum stretch factor is 4000.
The stretch factor is only applied to outline fonts. The stretch factor is ignored for bitmap fonts.
Definition at line 530 of file qtextformat.h.
|
inline |
If 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.
Definition at line 515 of file qtextformat.h.
|
inline |
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.
Definition at line 535 of file qtextformat.h.
Sets the text format's font styleName.
Definition at line 466 of file qtextformat.h.
|
inline |
Sets the font style strategy.
Definition at line 537 of file qtextformat.h.
|
inline |
If underline is true, sets the text format's font to be underlined; otherwise it is displayed non-underlined.
Definition at line 506 of file qtextformat.h.
|
inline |
Sets the text format's font weight to weight.
Definition at line 481 of file qtextformat.h.
Sets the word spacing of this format to the given spacing, in pixels.
Definition at line 501 of file qtextformat.h.
Sets the subscript's base line as a % of font height to baseline. The default value is 16.67% (1/6 of height)
Definition at line 583 of file qtextformat.h.
Sets the superscript's base line as a % of font height to baseline. The default value is 50% (1/2 of height).
Definition at line 578 of file qtextformat.h.
|
inline |
Definition at line 631 of file qtextformat.h.
|
inline |
Definition at line 623 of file qtextformat.h.
Sets the pen used to draw the outlines of characters to the given pen.
Definition at line 568 of file qtextformat.h.
Sets the tool tip for a fragment of text to the given text.
Definition at line 573 of file qtextformat.h.
Sets the color used to draw underlines, overlines and strikeouts on the characters with this format to the color specified.
Definition at line 520 of file qtextformat.h.
void QTextCharFormat::setUnderlineStyle | ( | UnderlineStyle | style | ) |
Sets the style of underlining the text to style.
Definition at line 1687 of file qtextformat.cpp.
|
inline |
Sets the vertical alignment used for the characters with this format to the alignment specified.
Definition at line 563 of file qtextformat.h.
|
inline |
Returns the subscript's base line as a % of font height.
Definition at line 585 of file qtextformat.h.
|
inline |
Returns the superscript's base line as a % of font height.
Definition at line 580 of file qtextformat.h.
|
inline |
Definition at line 611 of file qtextformat.h.
|
inline |
Definition at line 608 of file qtextformat.h.
|
inline |
Returns the pen used to draw the outlines of characters in this format.
Definition at line 570 of file qtextformat.h.
|
inline |
Returns the tool tip that is displayed for a fragment of text.
Definition at line 575 of file qtextformat.h.
|
inline |
Returns the color used to draw underlines, overlines and strikeouts on the characters with this format.
Definition at line 522 of file qtextformat.h.
|
inline |
Returns the style of underlining the text.
Definition at line 560 of file qtextformat.h.
|
inline |
Returns the vertical alignment used for characters with this format.
Definition at line 565 of file qtextformat.h.
|
friend |
Definition at line 500 of file qtextformat.cpp.
|
friend |
Definition at line 505 of file qtextformat.cpp.
|
friend |
Definition at line 616 of file qtextformat.h.