Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QTextCharFormat Class

TheQTextCharFormat class provides formatting information for characters in aQTextDocument.More...

Header:#include <QTextCharFormat>
Inherits:QTextFormat
Inherited By:

QTextImageFormat andQTextTableCellFormat

Note: All functions in this class arereentrant.

Public Types

enumUnderlineStyle { NoUnderline, SingleUnderline, DashUnderline, DotLine, ..., SpellCheckUnderline }
enumVerticalAlignment { AlignNormal, AlignSuperScript, AlignSubScript, AlignMiddle, ..., AlignBaseline }

Public Functions

QTextCharFormat()
QStringanchorHref() const
QStringListanchorNames() const
QFontfont() const
QFont::CapitalizationfontCapitalization() const
QStringfontFamily() const
boolfontFixedPitch() const
QFont::HintingPreferencefontHintingPreference() const
boolfontItalic() const
boolfontKerning() const
qrealfontLetterSpacing() const
boolfontOverline() const
qrealfontPointSize() const
boolfontStrikeOut() const
QFont::StyleHintfontStyleHint() const
QFont::StyleStrategyfontStyleStrategy() const
boolfontUnderline() const
intfontWeight() const
qrealfontWordSpacing() const
boolisAnchor() const
boolisValid() const
voidsetAnchor(bool anchor)
voidsetAnchorHref(const QString & value)
voidsetAnchorNames(const QStringList & names)
voidsetFont(const QFont & font)
voidsetFontCapitalization(QFont::Capitalization capitalization)
voidsetFontFamily(const QString & family)
voidsetFontFixedPitch(bool fixedPitch)
voidsetFontHintingPreference(QFont::HintingPreference hintingPreference)
voidsetFontItalic(bool italic)
voidsetFontKerning(bool enable)
voidsetFontLetterSpacing(qreal spacing)
voidsetFontOverline(bool overline)
voidsetFontPointSize(qreal size)
voidsetFontStrikeOut(bool strikeOut)
voidsetFontStyleHint(QFont::StyleHint hint, QFont::StyleStrategy strategy = QFont::PreferDefault)
voidsetFontStyleStrategy(QFont::StyleStrategy strategy)
voidsetFontUnderline(bool underline)
voidsetFontWeight(int weight)
voidsetFontWordSpacing(qreal spacing)
voidsetTextOutline(const QPen & pen)
voidsetToolTip(const QString & text)
voidsetUnderlineColor(const QColor & color)
voidsetUnderlineStyle(UnderlineStyle style)
voidsetVerticalAlignment(VerticalAlignment alignment)
QPentextOutline() const
QStringtoolTip() const
QColorunderlineColor() const
UnderlineStyleunderlineStyle() const
VerticalAlignmentverticalAlignment() const

Detailed Description

TheQTextCharFormat class provides formatting information for characters in aQTextDocument.

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 thesetFont() function, and each aspect of its appearance can be adjusted to give the desired effect.setFontFamily() andsetFontPointSize() define the font's family (e.g. Times) and printed size;setFontWeight() andsetFontItalic() provide control over the style of the font.setFontUnderline(),setFontOverline(),setFontStrikeOut(), andsetFontFixedPitch() provide additional effects for text.

The color is set withsetForeground(). If the text is intended to be used as an anchor (for hyperlinks), this can be enabled withsetAnchor(). ThesetAnchorHref() andsetAnchorNames() functions are used to specify the information about the hyperlink's destination and the anchor's name.

See alsoQTextFormat,QTextBlockFormat,QTextTableFormat, andQTextListFormat.

Member Type Documentation

enum QTextCharFormat::UnderlineStyle

This enum describes the different ways drawing underlined text.

ConstantValueDescription
QTextCharFormat::NoUnderline0Text is draw without any underlining decoration.
QTextCharFormat::SingleUnderline1A line is drawn usingQt::SolidLine.
QTextCharFormat::DashUnderline2Dashes are drawn usingQt::DashLine.
QTextCharFormat::DotLine3Dots are drawn usingQt::DotLine;
QTextCharFormat::DashDotLine4Dashs and dots are drawn usingQt::DashDotLine.
QTextCharFormat::DashDotDotLine5Underlines draw drawn usingQt::DashDotDotLine.
QTextCharFormat::WaveUnderline6The text is underlined using a wave shaped line.
QTextCharFormat::SpellCheckUnderline7The underline is drawn depending on the QStyle::SH_SpellCeckUnderlineStyle style hint of theQApplication style. By default this is mapped to WaveUnderline, on Mac OS X it is mapped to DashDotLine.

See alsoQt::PenStyle.

enum QTextCharFormat::VerticalAlignment

This enum describes the ways that adjacent characters can be vertically aligned.

ConstantValueDescription
QTextCharFormat::AlignNormal0Adjacent characters are positioned in the standard way for text in the writing system in use.
QTextCharFormat::AlignSuperScript1Characters are placed above the base line for normal text.
QTextCharFormat::AlignSubScript2Characters are placed below the base line for normal text.
QTextCharFormat::AlignMiddle3The center of the object is vertically aligned with the base line. Currently, this is only implemented for inline objects.
QTextCharFormat::AlignBottom5The bottom edge of the object is vertically aligned with the base line.
QTextCharFormat::AlignTop4The top edge of the object is vertically aligned with the base line.
QTextCharFormat::AlignBaseline6The base lines of the characters are aligned.

Member Function Documentation

QTextCharFormat::QTextCharFormat()

Constructs a new character format object.

QString QTextCharFormat::anchorHref() const

Returns the text format's hypertext link, or an empty string if none has been set.

See alsosetAnchorHref().

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.

This function was introduced in Qt 4.3.

See alsosetAnchorNames().

QFont QTextCharFormat::font() const

Returns the font for this character format.

See alsosetFont().

QFont::Capitalization QTextCharFormat::fontCapitalization() const

Returns the current capitalization type of the font.

This function was introduced in Qt 4.4.

See alsosetFontCapitalization().

QString QTextCharFormat::fontFamily() const

Returns the text format's font family.

See alsosetFontFamily() andfont().

bool QTextCharFormat::fontFixedPitch() const

Returns true if the text format's font is fixed pitch; otherwise returns false.

See alsosetFontFixedPitch() andfont().

QFont::HintingPreference QTextCharFormat::fontHintingPreference() const

Returns the hinting preference set for this text format.

This function was introduced in Qt 4.8.

See alsosetFontHintingPreference(),font(), andQFont::hintingPreference().

bool QTextCharFormat::fontItalic() const

Returns true if the text format's font is italic; otherwise returns false.

See alsosetFontItalic() andfont().

bool QTextCharFormat::fontKerning() const

Returns true if the font kerning is enabled.

This function was introduced in Qt 4.5.

See alsosetFontKerning() andfont().

qreal QTextCharFormat::fontLetterSpacing() const

Returns the current letter spacing percentage.

This function was introduced in Qt 4.4.

See alsosetFontLetterSpacing().

bool QTextCharFormat::fontOverline() const

Returns true if the text format's font is overlined; otherwise returns false.

See alsosetFontOverline() andfont().

qreal QTextCharFormat::fontPointSize() const

Returns the font size used to display text in this format.

See alsosetFontPointSize() andfont().

bool QTextCharFormat::fontStrikeOut() const

Returns true if the text format's font is struck out (has a horizontal line drawn through it); otherwise returns false.

See alsosetFontStrikeOut() andfont().

QFont::StyleHint QTextCharFormat::fontStyleHint() const

Returns the font style hint.

This function was introduced in Qt 4.5.

See alsosetFontStyleHint() andfont().

QFont::StyleStrategy QTextCharFormat::fontStyleStrategy() const

Returns the current font style strategy.

This function was introduced in Qt 4.5.

See alsosetFontStyleStrategy() andfont().

bool QTextCharFormat::fontUnderline() const

Returns true if the text format's font is underlined; otherwise returns false.

See alsosetFontUnderline() andfont().

int QTextCharFormat::fontWeight() const

Returns the text format's font weight.

See alsosetFontWeight(),font(), andQFont::Weight.

qreal QTextCharFormat::fontWordSpacing() const

Returns the current word spacing value.

This function was introduced in Qt 4.4.

See alsosetFontWordSpacing().

bool QTextCharFormat::isAnchor() const

Returns true if the text is formatted as an anchor; otherwise returns false.

See alsosetAnchor(),setAnchorHref(), andsetAnchorNames().

bool QTextCharFormat::isValid() const

Returns true if this character format is valid; otherwise returns false.

void QTextCharFormat::setAnchor(bool anchor)

Ifanchor 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. UsesetAnchorHref(), and optionallysetAnchorNames() to create a hypertext link.

See alsoisAnchor().

void QTextCharFormat::setAnchorHref(constQString & value)

Sets the hypertext link for the text format to the givenvalue. This is typically a URL like "http://example.com/index.html".

The anchor will be displayed with thevalue as its display text; if you want to display different text callsetAnchorNames().

To format the text as a hypertext link usesetAnchor().

See alsoanchorHref().

void QTextCharFormat::setAnchorNames(constQStringList & names)

Sets the text format's anchornames. For the anchor to work as a hyperlink, the destination must be set withsetAnchorHref() and the anchor must be enabled withsetAnchor().

This function was introduced in Qt 4.3.

See alsoanchorNames().

void QTextCharFormat::setFont(constQFont & font)

Sets the text format'sfont.

See alsofont().

void QTextCharFormat::setFontCapitalization(QFont::Capitalization capitalization)

Sets the capitalization of the text that apppears in this font tocapitalization.

A font's capitalization makes the text appear in the selected capitalization mode.

This function was introduced in Qt 4.4.

See alsofontCapitalization().

void QTextCharFormat::setFontFamily(constQString & family)

Sets the text format's fontfamily.

See alsofontFamily() andsetFont().

void QTextCharFormat::setFontFixedPitch(bool fixedPitch)

IffixedPitch is true, sets the text format's font to be fixed pitch; otherwise a non-fixed pitch font is used.

See alsofontFixedPitch() andsetFont().

void QTextCharFormat::setFontHintingPreference(QFont::HintingPreference hintingPreference)

Sets the hinting preference of the text format's font to behintingPreference.

This function was introduced in Qt 4.8.

See alsofontHintingPreference(),setFont(), andQFont::setHintingPreference().

void QTextCharFormat::setFontItalic(bool italic)

Ifitalic is true, sets the text format's font to be italic; otherwise the font will be non-italic.

See alsofontItalic() andsetFont().

void QTextCharFormat::setFontKerning(bool enable)

Enables kerning for this font ifenable 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.

This function was introduced in Qt 4.5.

See alsofontKerning() andsetFont().

void QTextCharFormat::setFontLetterSpacing(qreal spacing)

Sets the letter spacing of this format to the givenspacing, in percent. A value of 100 indicates default spacing; a value of 200 doubles the amount of space a letter takes.

This function was introduced in Qt 4.4.

See alsofontLetterSpacing().

void QTextCharFormat::setFontOverline(bool overline)

Ifoverline is true, sets the text format's font to be overlined; otherwise the font is displayed non-overlined.

See alsofontOverline() andsetFont().

void QTextCharFormat::setFontPointSize(qreal size)

Sets the text format's fontsize.

See alsofontPointSize() andsetFont().

void QTextCharFormat::setFontStrikeOut(bool strikeOut)

IfstrikeOut is true, sets the text format's font with strike-out enabled (with a horizontal line through it); otherwise it is displayed without strikeout.

See alsofontStrikeOut() andsetFont().

void QTextCharFormat::setFontStyleHint(QFont::StyleHint hint,QFont::StyleStrategy strategy = QFont::PreferDefault)

Sets the font stylehint andstrategy.

Qt does not support style hints on X11 since this information is not provided by the window system.

This function was introduced in Qt 4.5.

See alsofontStyleHint(),setFont(), andQFont::setStyleHint().

void QTextCharFormat::setFontStyleStrategy(QFont::StyleStrategy strategy)

Sets the font stylestrategy.

This function was introduced in Qt 4.5.

See alsofontStyleStrategy(),setFont(), andQFont::setStyleStrategy().

void QTextCharFormat::setFontUnderline(bool underline)

Ifunderline is true, sets the text format's font to be underlined; otherwise it is displayed non-underlined.

See alsofontUnderline() andsetFont().

void QTextCharFormat::setFontWeight(int weight)

Sets the text format's font weight toweight.

See alsofontWeight(),setFont(), andQFont::Weight.

void QTextCharFormat::setFontWordSpacing(qreal spacing)

Sets the word spacing of this format to the givenspacing, in pixels.

This function was introduced in Qt 4.4.

See alsofontWordSpacing().

void QTextCharFormat::setTextOutline(constQPen & pen)

Sets the pen used to draw the outlines of characters to the givenpen.

See alsotextOutline().

void QTextCharFormat::setToolTip(constQString & text)

Sets the tool tip for a fragment of text to the giventext.

This function was introduced in Qt 4.3.

See alsotoolTip().

void QTextCharFormat::setUnderlineColor(constQColor & color)

Sets the underline color used for the characters with this format to thecolor specified.

See alsounderlineColor().

void QTextCharFormat::setUnderlineStyle(UnderlineStyle style)

Sets the style of underlining the text tostyle.

This function was introduced in Qt 4.2.

See alsounderlineStyle().

void QTextCharFormat::setVerticalAlignment(VerticalAlignment alignment)

Sets the vertical alignment used for the characters with this format to thealignment specified.

See alsoverticalAlignment().

QPen QTextCharFormat::textOutline() const

Returns the pen used to draw the outlines of characters in this format.

See alsosetTextOutline().

QString QTextCharFormat::toolTip() const

Returns the tool tip that is displayed for a fragment of text.

This function was introduced in Qt 4.3.

See alsosetToolTip().

QColor QTextCharFormat::underlineColor() const

Returns the color used to underline the characters with this format.

See alsosetUnderlineColor().

UnderlineStyle QTextCharFormat::underlineStyle() const

Returns the style of underlining the text.

This function was introduced in Qt 4.2.

See alsosetUnderlineStyle().

VerticalAlignment QTextCharFormat::verticalAlignment() const

Returns the vertical alignment used for characters with this format.

See alsosetVerticalAlignment().

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp