QTextCharFormat Class
The QTextCharFormat class provides formatting information for characters in a QTextDocument. More…
| Header | #include <QTextCharFormat> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Gui) |
| Module | Nt GUI C++ Classes |
| Inherits | QTextFormat |
List of all members, including inherited members
Public Functions
| QTextCharFormat() | |
| void | setFont(const QFont &font) |
| QFont | font() const |
| void | setFontFamilies(const QStringList &families) |
| QStringList | fontFamilies() const |
| void | setFontPointSize(qreal size) |
| qreal | fontPointSize() const |
| void | setFontWeight(int weight) |
| int | fontWeight() const |
| void | setFontItalic(bool italic) |
| bool | fontItalic() const |
| void | setFontUnderline(bool underline) |
| bool | fontUnderline() const |
| void | setFontStrikeOut(bool strikeOut) |
| bool | fontStrikeOut() const |
| void | setFontFixedPitch(bool fixedPitch) |
| bool | fontFixedPitch() const |
| void | setAnchor(bool anchor) |
| bool | isAnchor() const |
| void | setAnchorHref(const QString &value) |
| QString | anchorHref() const |
Detailed Description
A character format says how a piece of text looks: its font family, size, weight and slant, whether it is underlined or struck out, its colors, and whether it is a link.
QTextCharFormat warning;
warning.setFontWeight(QFont::Bold);
warning.setForeground(QBrush(Qt::red));
See also QTextFormat, QTextLayout and QTextDocument.
Differences from Qt
There are no outlines, tool tips, vertical alignments (subscript and superscript), letter and word spacing, capitalization, underline styles and colors, and no anchor names. The font is made of the properties that Nt's QFont has.
Member Function Documentation
QTextCharFormat::QTextCharFormat()
Constructs a character format without properties.
QString QTextCharFormat::anchorHref() const
Returns the target of the link, or an empty string.
QFont QTextCharFormat::font() const
Returns a font made of the font properties of the format. A property that is not set leaves the default of QFont.
See also setFont().
QStringList QTextCharFormat::fontFamilies() const
Returns the families of the font, or an empty list if none are set.
bool QTextCharFormat::fontFixedPitch() const
Returns whether the text is in a font of fixed pitch.
bool QTextCharFormat::fontItalic() const
Returns whether the font is italic.
qreal QTextCharFormat::fontPointSize() const
Returns the size of the font in points, or 0 if none is set.
bool QTextCharFormat::fontStrikeOut() const
Returns whether the text is struck out.
bool QTextCharFormat::fontUnderline() const
Returns whether the text is underlined.
int QTextCharFormat::fontWeight() const
Returns the weight of the font; QFont::Normal if none is set.
bool QTextCharFormat::isAnchor() const
Returns whether the text is a link.
void QTextCharFormat::setAnchor(bool anchor)
Sets whether the text is a link to anchor.
See also setAnchorHref().
void QTextCharFormat::setAnchorHref(const QString &value)
Sets the target of the link to value, a URL as text.
void QTextCharFormat::setFont(const QFont &font)
Sets the font properties of the format to those of font: its families, point size, weight and slant.
See also font().
void QTextCharFormat::setFontFamilies(const QStringList &families)
Sets the families of the font to families, in order of preference. The first one is used.
void QTextCharFormat::setFontFixedPitch(bool fixedPitch)
Sets whether the text is in a font of fixed pitch to fixedPitch. Such text is drawn in the monospace family unless families are set.
void QTextCharFormat::setFontItalic(bool italic)
Sets whether the font is italic to italic.
void QTextCharFormat::setFontPointSize(qreal size)
Sets the size of the font to size points.
void QTextCharFormat::setFontStrikeOut(bool strikeOut)
Sets whether the text is struck out to strikeOut.
void QTextCharFormat::setFontUnderline(bool underline)
Sets whether the text is underlined to underline.
void QTextCharFormat::setFontWeight(int weight)
Sets the weight of the font to weight, a QFont::Weight value.