6.0.0-rc4Source

QTextCharFormat Class

The QTextCharFormat class provides formatting information for characters in a QTextDocument. More…

Header#include <QTextCharFormat>
CMaketarget_link_libraries(app PRIVATE Nt::Gui)
ModuleNt GUI C++ Classes
InheritsQTextFormat

List of all members, including inherited members

Public Functions

QTextCharFormat()
voidsetFont(const QFont &font)
QFontfont() const
voidsetFontFamilies(const QStringList &families)
QStringListfontFamilies() const
voidsetFontPointSize(qreal size)
qrealfontPointSize() const
voidsetFontWeight(int weight)
intfontWeight() const
voidsetFontItalic(bool italic)
boolfontItalic() const
voidsetFontUnderline(bool underline)
boolfontUnderline() const
voidsetFontStrikeOut(bool strikeOut)
boolfontStrikeOut() const
voidsetFontFixedPitch(bool fixedPitch)
boolfontFixedPitch() const
voidsetAnchor(bool anchor)
boolisAnchor() const
voidsetAnchorHref(const QString &value)
QStringanchorHref() 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.