![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\reentrant More...
#include <qtextformat.h>
Public Member Functions | |
QTextCharFormat () | |
Constructs a new character format object. | |
bool | isValid () const |
Returns true if this character format is valid; otherwise returns false. | |
void | setFont (const QFont &font, FontPropertiesInheritanceBehavior behavior=FontPropertiesAll) |
QFont | font () const |
Returns the font for this character format. | |
void | setFontFamilies (const QStringList &families) |
QStringList | fontFamilies () const |
void | setFontStyleName (const QString &styleName) |
QStringList | fontStyleName () const |
void | setFontPointSize (qreal size) |
Sets the text format's font size. | |
qreal | fontPointSize () const |
Returns the font size used to display text in this format. | |
void | setFontWeight (int weight) |
Sets the text format's font weight to weight. | |
int | fontWeight () const |
Returns the text format's font weight. | |
void | setFontItalic (bool italic) |
If italic is true, sets the text format's font to be italic; otherwise the font will be non-italic. | |
bool | fontItalic () const |
Returns true if the text format's font is italic; otherwise returns false . | |
void | setFontCapitalization (QFont::Capitalization capitalization) |
QFont::Capitalization | fontCapitalization () const |
void | setFontLetterSpacingType (QFont::SpacingType letterSpacingType) |
QFont::SpacingType | fontLetterSpacingType () const |
void | setFontLetterSpacing (qreal spacing) |
qreal | fontLetterSpacing () const |
void | setFontWordSpacing (qreal spacing) |
qreal | fontWordSpacing () const |
void | setFontUnderline (bool underline) |
If underline is true, sets the text format's font to be underlined; otherwise it is displayed non-underlined. | |
bool | fontUnderline () const |
Returns true if the text format's font is underlined; otherwise returns false . | |
void | setFontOverline (bool overline) |
If overline is true, sets the text format's font to be overlined; otherwise the font is displayed non-overlined. | |
bool | fontOverline () const |
Returns true if the text format's font is overlined; otherwise returns false . | |
void | setFontStrikeOut (bool strikeOut) |
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. | |
bool | fontStrikeOut () const |
Returns true if the text format's font is struck out (has a horizontal line drawn through it); otherwise returns false . | |
void | setUnderlineColor (const QColor &color) |
Sets the color used to draw underlines, overlines and strikeouts on the characters with this format to the color specified. | |
QColor | underlineColor () const |
Returns the color used to draw underlines, overlines and strikeouts on the characters with this format. | |
void | setFontFixedPitch (bool fixedPitch) |
If fixedPitch is true, sets the text format's font to be fixed pitch; otherwise a non-fixed pitch font is used. | |
bool | fontFixedPitch () const |
Returns true if the text format's font is fixed pitch; otherwise returns false . | |
void | setFontStretch (int factor) |
int | fontStretch () const |
void | setFontStyleHint (QFont::StyleHint hint, QFont::StyleStrategy strategy=QFont::PreferDefault) |
void | setFontStyleStrategy (QFont::StyleStrategy strategy) |
QFont::StyleHint | fontStyleHint () const |
QFont::StyleStrategy | fontStyleStrategy () const |
void | setFontHintingPreference (QFont::HintingPreference hintingPreference) |
QFont::HintingPreference | fontHintingPreference () const |
void | setFontKerning (bool enable) |
bool | fontKerning () const |
void | setUnderlineStyle (UnderlineStyle style) |
UnderlineStyle | underlineStyle () const |
void | setVerticalAlignment (VerticalAlignment alignment) |
Sets the vertical alignment used for the characters with this format to the alignment specified. | |
VerticalAlignment | verticalAlignment () const |
Returns the vertical alignment used for characters with this format. | |
void | setTextOutline (const QPen &pen) |
Sets the pen used to draw the outlines of characters to the given pen. | |
QPen | textOutline () const |
Returns the pen used to draw the outlines of characters in this format. | |
void | setToolTip (const QString &tip) |
QString | toolTip () const |
void | setSuperScriptBaseline (qreal baseline) |
qreal | superScriptBaseline () const |
void | setSubScriptBaseline (qreal baseline) |
qreal | subScriptBaseline () const |
void | setBaselineOffset (qreal baseline) |
qreal | baselineOffset () const |
void | setAnchor (bool anchor) |
If anchor is true, text with this format represents an anchor, and is formatted in the appropriate way; otherwise the text is formatted normally. | |
bool | isAnchor () const |
Returns true if the text is formatted as an anchor; otherwise returns false . | |
void | setAnchorHref (const QString &value) |
Sets the hypertext link for the text format to the given value. | |
QString | anchorHref () const |
Returns the text format's hypertext link, or an empty string if none has been set. | |
void | setAnchorNames (const QStringList &names) |
QStringList | anchorNames () const |
void | setTableCellRowSpan (int tableCellRowSpan) |
int | tableCellRowSpan () const |
void | setTableCellColumnSpan (int tableCellColumnSpan) |
int | tableCellColumnSpan () const |
![]() | |
QTextFormat () | |
Creates a new text format with an InvalidFormat . | |
QTextFormat (int type) | |
Creates a new text format of the given type. | |
QTextFormat (const QTextFormat &rhs) | |
Creates a new text format with the same attributes as the other text format. | |
QTextFormat & | operator= (const QTextFormat &rhs) |
Assigns the other text format to this text format, and returns a reference to this text format. | |
~QTextFormat () | |
Destroys this text format. | |
void | swap (QTextFormat &other) |
void | merge (const QTextFormat &other) |
Merges the other format with this format; where there are conflicts the other format takes precedence. | |
bool | isValid () const |
Returns true if the format is valid (i.e. | |
bool | isEmpty () const |
int | type () const |
Returns the type of this format. | |
int | objectIndex () const |
Returns the index of the format object, or -1 if the format object is invalid. | |
void | setObjectIndex (int object) |
Sets the format object's object index. | |
QVariant | property (int propertyId) const |
Returns the property specified by the given propertyId. | |
void | setProperty (int propertyId, const QVariant &value) |
Sets the property specified by the propertyId to the given value. | |
void | clearProperty (int propertyId) |
Clears the value of the property given by propertyId. | |
bool | hasProperty (int propertyId) const |
Returns true if the text format has a property with the given propertyId; otherwise returns false . | |
bool | boolProperty (int propertyId) const |
Returns the value of the property specified by propertyId. | |
int | intProperty (int propertyId) const |
Returns the value of the property specified by propertyId. | |
qreal | doubleProperty (int propertyId) const |
Returns the value of the property specified by propertyId. | |
QString | stringProperty (int propertyId) const |
Returns the value of the property given by propertyId; if the property isn't of QMetaType::QString type, an empty string is returned instead. | |
QColor | colorProperty (int propertyId) const |
Returns the value of the property given by propertyId; if the property isn't of QMetaType::QColor type, an invalid color is returned instead. | |
QPen | penProperty (int propertyId) const |
Returns the value of the property given by propertyId; if the property isn't of QMetaType::QPen type, Qt::NoPen is returned instead. | |
QBrush | brushProperty (int propertyId) const |
Returns the value of the property given by propertyId; if the property isn't of QMetaType::QBrush type, Qt::NoBrush is returned instead. | |
QTextLength | lengthProperty (int propertyId) const |
Returns the value of the property given by propertyId. | |
QList< QTextLength > | lengthVectorProperty (int propertyId) const |
Returns the value of the property given by propertyId. | |
void | setProperty (int propertyId, const QList< QTextLength > &lengths) |
Sets the value of the property given by propertyId to value. | |
QMap< int, QVariant > | properties () const |
Returns a map with all properties of this text format. | |
int | propertyCount () const |
void | setObjectType (int type) |
Sets the text format's object type to type. | |
int | objectType () const |
Returns the text format's object type. | |
bool | isCharFormat () const |
Returns true if this text format is a CharFormat ; otherwise returns false . | |
bool | isBlockFormat () const |
Returns true if this text format is a BlockFormat ; otherwise returns false . | |
bool | isListFormat () const |
Returns true if this text format is a ListFormat ; otherwise returns false . | |
bool | isFrameFormat () const |
Returns true if this text format is a FrameFormat ; otherwise returns false . | |
bool | isImageFormat () const |
Returns true if this text format is an image format; otherwise returns false . | |
bool | isTableFormat () const |
Returns true if this text format is a TableFormat ; otherwise returns false . | |
bool | isTableCellFormat () const |
QTextBlockFormat | toBlockFormat () const |
Returns this format as a block format. | |
QTextCharFormat | toCharFormat () const |
Returns this format as a character format. | |
QTextListFormat | toListFormat () const |
Returns this format as a list format. | |
QTextTableFormat | toTableFormat () const |
Returns this format as a table format. | |
QTextFrameFormat | toFrameFormat () const |
Returns this format as a frame format. | |
QTextImageFormat | toImageFormat () const |
Returns this format as an image format. | |
QTextTableCellFormat | toTableCellFormat () const |
bool | operator== (const QTextFormat &rhs) const |
Returns true if this text format is the same as the other text format. | |
bool | operator!= (const QTextFormat &rhs) const |
Returns true if this text format is different from the other text format. | |
operator QVariant () const | |
Returns the text format as a QVariant. | |
void | setLayoutDirection (Qt::LayoutDirection direction) |
Sets the document's layout direction to the specified direction. | |
Qt::LayoutDirection | layoutDirection () const |
Returns the document's layout direction. | |
void | setBackground (const QBrush &brush) |
Sets the brush use to paint the document's background to the brush specified. | |
QBrush | background () const |
Returns the brush used to paint the document's background. | |
void | clearBackground () |
Clears the brush used to paint the document's background. | |
void | setForeground (const QBrush &brush) |
Sets the foreground brush to the specified brush. | |
QBrush | foreground () const |
Returns the brush used to render foreground details, such as text, frame outlines, and table borders. | |
void | clearForeground () |
Clears the brush used to paint the document's foreground. | |
Protected Member Functions | |
QTextCharFormat (const QTextFormat &fmt) | |
Friends | |
class | QTextFormat |
Q_GUI_EXPORT QDataStream & | operator<< (QDataStream &stream, const QTextCharFormat &fmt) |
Q_GUI_EXPORT QDataStream & | operator>> (QDataStream &stream, QTextCharFormat &fmt) |
\reentrant
The QTextCharFormat class provides formatting information for characters in a QTextDocument. \inmodule QtGui
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 382 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 409 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 394 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 385 of file qtextformat.h.
QTextCharFormat::QTextCharFormat | ( | ) |
Constructs a new character format object.
Definition at line 1456 of file qtextformat.cpp.
|
explicitprotected |
Creates a new character format with the same attributes as the given text format.
Definition at line 1465 of file qtextformat.cpp.
|
inline |
Returns the text format's hypertext link, or an empty string if none has been set.
Definition at line 567 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 1987 of file qtextformat.cpp.
|
inline |
Returns the the baseline offset in %.
Definition at line 557 of file qtextformat.h.
QFont QTextCharFormat::font | ( | ) | const |
Returns the font for this character format.
Definition at line 2153 of file qtextformat.cpp.
|
inline |
Returns the current capitalization type of the font.
Definition at line 458 of file qtextformat.h.
|
inline |
Definition at line 429 of file qtextformat.h.
|
inline |
Returns true
if the text format's font is fixed pitch; otherwise returns false
.
Definition at line 494 of file qtextformat.h.
|
inline |
Returns the hinting preference set for this text format.
Definition at line 516 of file qtextformat.h.
|
inline |
Returns true
if the text format's font is italic; otherwise returns false
.
Definition at line 454 of file qtextformat.h.
|
inline |
Returns true
if the font kerning is enabled.
Definition at line 523 of file qtextformat.h.
|
inline |
|
inline |
Returns the letter spacing type of this format..
Definition at line 462 of file qtextformat.h.
|
inline |
Returns true
if the text format's font is overlined; otherwise returns false
.
Definition at line 479 of file qtextformat.h.
|
inline |
Returns the font size used to display text in this format.
Definition at line 445 of file qtextformat.h.
|
inline |
Returns the current font stretching.
Definition at line 499 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 484 of file qtextformat.h.
|
inline |
Returns the font style hint.
Definition at line 506 of file qtextformat.h.
|
inline |
Definition at line 439 of file qtextformat.h.
|
inline |
Returns the current font style strategy.
Definition at line 508 of file qtextformat.h.
bool QTextCharFormat::fontUnderline | ( | ) | const |
Returns true
if the text format's font is underlined; otherwise returns false
.
Definition at line 1637 of file qtextformat.cpp.
|
inline |
Returns the text format's font weight.
Definition at line 450 of file qtextformat.h.
|
inline |
|
inline |
Returns true
if the text is formatted as an anchor; otherwise returns false
.
Definition at line 562 of file qtextformat.h.
|
inline |
Returns true
if this character format is valid; otherwise returns false.
Definition at line 407 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 560 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 565 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 570 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 555 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 2097 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 456 of file qtextformat.h.
|
inline |
Sets the text format's font families.
Definition at line 423 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 492 of file qtextformat.h.
|
inline |
Sets the hinting preference of the text format's font to be hintingPreference.
Definition at line 511 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 452 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 521 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 464 of file qtextformat.h.
|
inline |
Sets the letter spacing type of this format to letterSpacingType.
Definition at line 460 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 477 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 497 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 482 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 502 of file qtextformat.h.
Sets the text format's font styleName.
Definition at line 433 of file qtextformat.h.
|
inline |
Sets the font style strategy.
Definition at line 504 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 473 of file qtextformat.h.
|
inline |
Sets the text format's font weight to weight.
Definition at line 448 of file qtextformat.h.
Sets the word spacing of this format to the given spacing, in pixels.
Definition at line 468 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 550 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 545 of file qtextformat.h.
|
inline |
If this character format is applied to characters in a table cell, the cell will span tableCellColumnSpan columns.
Definition at line 598 of file qtextformat.h.
|
inline |
If this character format is applied to characters in a table cell, the cell will span tableCellRowSpan rows.
Definition at line 590 of file qtextformat.h.
Sets the pen used to draw the outlines of characters to the given pen.
Definition at line 535 of file qtextformat.h.
Sets the tool tip for a fragment of text to the given text.
Definition at line 540 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 487 of file qtextformat.h.
void QTextCharFormat::setUnderlineStyle | ( | UnderlineStyle | style | ) |
Sets the style of underlining the text to style.
Definition at line 1657 of file qtextformat.cpp.
|
inline |
Sets the vertical alignment used for the characters with this format to the alignment specified.
Definition at line 530 of file qtextformat.h.
|
inline |
Returns the subscript's base line as a % of font height.
Definition at line 552 of file qtextformat.h.
|
inline |
Returns the superscript's base line as a % of font height.
Definition at line 547 of file qtextformat.h.
|
inline |
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.
Definition at line 578 of file qtextformat.h.
|
inline |
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.
Definition at line 575 of file qtextformat.h.
|
inline |
Returns the pen used to draw the outlines of characters in this format.
Definition at line 537 of file qtextformat.h.
|
inline |
Returns the tool tip that is displayed for a fragment of text.
Definition at line 542 of file qtextformat.h.
|
inline |
Returns the color used to draw underlines, overlines and strikeouts on the characters with this format.
Definition at line 489 of file qtextformat.h.
|
inline |
|
inline |
Returns the vertical alignment used for characters with this format.
Definition at line 532 of file qtextformat.h.
|
friend |
Definition at line 464 of file qtextformat.cpp.
|
friend |
Definition at line 469 of file qtextformat.cpp.
|
friend |
Definition at line 583 of file qtextformat.h.