QtBase  v6.3.1
Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
QTextCharFormat Class Reference

The QTextCharFormat class provides formatting information for characters in a QTextDocument. \inmodule QtGui. More...

#include <qtextformat.h>

Inheritance diagram for QTextCharFormat:
Inheritance graph
[legend]
Collaboration diagram for QTextCharFormat:
Collaboration graph
[legend]

Public Types

enum  VerticalAlignment {
  AlignNormal = 0 , AlignSuperScript , AlignSubScript , AlignMiddle ,
  AlignTop , AlignBottom , AlignBaseline
}
 
enum  UnderlineStyle {
  NoUnderline , SingleUnderline , DashUnderline , DotLine ,
  DashDotLine , DashDotDotLine , WaveUnderline , SpellCheckUnderline
}
 
enum  FontPropertiesInheritanceBehavior { FontPropertiesSpecifiedOnly , FontPropertiesAll }
 
- Public Types inherited from QTextFormat
enum  FormatType {
  InvalidFormat = -1 , BlockFormat = 1 , CharFormat = 2 , ListFormat = 3 ,
  FrameFormat = 5 , UserFormat = 100
}
 
enum  Property {
  ObjectIndex = 0x0 , CssFloat = 0x0800 , LayoutDirection = 0x0801 , OutlinePen = 0x810 ,
  BackgroundBrush = 0x820 , ForegroundBrush = 0x821 , BackgroundImageUrl = 0x823 , BlockAlignment = 0x1010 ,
  BlockTopMargin = 0x1030 , BlockBottomMargin = 0x1031 , BlockLeftMargin = 0x1032 , BlockRightMargin = 0x1033 ,
  TextIndent = 0x1034 , TabPositions = 0x1035 , BlockIndent = 0x1040 , LineHeight = 0x1048 ,
  LineHeightType = 0x1049 , BlockNonBreakableLines = 0x1050 , BlockTrailingHorizontalRulerWidth = 0x1060 , HeadingLevel = 0x1070 ,
  BlockQuoteLevel = 0x1080 , BlockCodeLanguage = 0x1090 , BlockCodeFence = 0x1091 , BlockMarker = 0x10A0 ,
  FirstFontProperty = 0x1FE0 , FontCapitalization = FirstFontProperty , FontLetterSpacing = 0x1FE1 , FontWordSpacing = 0x1FE2 ,
  FontStyleHint = 0x1FE3 , FontStyleStrategy = 0x1FE4 , FontKerning = 0x1FE5 , FontHintingPreference = 0x1FE6 ,
  FontFamilies = 0x1FE7 , FontStyleName = 0x1FE8 , FontLetterSpacingType = 0x1FE9 , FontStretch = 0x1FEA ,
  FontPointSize = 0x2001 , FontSizeAdjustment = 0x2002 , FontSizeIncrement = FontSizeAdjustment , FontWeight = 0x2003 ,
  FontItalic = 0x2004 , FontUnderline = 0x2005 , FontOverline = 0x2006 , FontStrikeOut = 0x2007 ,
  FontFixedPitch = 0x2008 , FontPixelSize = 0x2009 , LastFontProperty = FontPixelSize , TextUnderlineColor = 0x2020 ,
  TextVerticalAlignment = 0x2021 , TextOutline = 0x2022 , TextUnderlineStyle = 0x2023 , TextToolTip = 0x2024 ,
  TextSuperScriptBaseline = 0x2025 , TextSubScriptBaseline = 0x2026 , TextBaselineOffset = 0x2027 , IsAnchor = 0x2030 ,
  AnchorHref = 0x2031 , AnchorName = 0x2032 , OldFontLetterSpacingType = 0x2033 , OldFontStretch = 0x2034 ,
  OldTextUnderlineColor = 0x2010 , ObjectType = 0x2f00 , ListStyle = 0x3000 , ListIndent = 0x3001 ,
  ListNumberPrefix = 0x3002 , ListNumberSuffix = 0x3003 , FrameBorder = 0x4000 , FrameMargin = 0x4001 ,
  FramePadding = 0x4002 , FrameWidth = 0x4003 , FrameHeight = 0x4004 , FrameTopMargin = 0x4005 ,
  FrameBottomMargin = 0x4006 , FrameLeftMargin = 0x4007 , FrameRightMargin = 0x4008 , FrameBorderBrush = 0x4009 ,
  FrameBorderStyle = 0x4010 , TableColumns = 0x4100 , TableColumnWidthConstraints = 0x4101 , TableCellSpacing = 0x4102 ,
  TableCellPadding = 0x4103 , TableHeaderRowCount = 0x4104 , TableBorderCollapse = 0x4105 , TableCellRowSpan = 0x4810 ,
  TableCellColumnSpan = 0x4811 , TableCellTopPadding = 0x4812 , TableCellBottomPadding = 0x4813 , TableCellLeftPadding = 0x4814 ,
  TableCellRightPadding = 0x4815 , TableCellTopBorder = 0x4816 , TableCellBottomBorder = 0x4817 , TableCellLeftBorder = 0x4818 ,
  TableCellRightBorder = 0x4819 , TableCellTopBorderStyle = 0x481a , TableCellBottomBorderStyle = 0x481b , TableCellLeftBorderStyle = 0x481c ,
  TableCellRightBorderStyle = 0x481d , TableCellTopBorderBrush = 0x481e , TableCellBottomBorderBrush = 0x481f , TableCellLeftBorderBrush = 0x4820 ,
  TableCellRightBorderBrush = 0x4821 , ImageName = 0x5000 , ImageTitle = 0x5001 , ImageAltText = 0x5002 ,
  ImageWidth = 0x5010 , ImageHeight = 0x5011 , ImageQuality = 0x5014 , FullWidthSelection = 0x06000 ,
  PageBreakPolicy = 0x7000 , UserProperty = 0x100000
}
 
enum  ObjectTypes {
  NoObject , ImageObject , TableObject , TableCellObject ,
  UserObject = 0x1000
}
 
enum  PageBreakFlag { PageBreak_Auto = 0 , PageBreak_AlwaysBefore = 0x001 , PageBreak_AlwaysAfter = 0x010 }
 

Public Member Functions

 QTextCharFormat ()
 
bool isValid () const
 
void setFont (const QFont &font, FontPropertiesInheritanceBehavior behavior=FontPropertiesAll)
 
QFont font () const
 
void setFontFamilies (const QStringList &families)
 
QStringList fontFamilies () const
 
void setFontStyleName (const QString &styleName)
 
QStringList fontStyleName () const
 
void setFontPointSize (qreal size)
 
qreal fontPointSize () const
 
void setFontWeight (int weight)
 
int fontWeight () const
 
void setFontItalic (bool italic)
 
bool fontItalic () const
 
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)
 
bool fontUnderline () const
 
void setFontOverline (bool overline)
 
bool fontOverline () const
 
void setFontStrikeOut (bool strikeOut)
 
bool fontStrikeOut () const
 
void setUnderlineColor (const QColor &color)
 
QColor underlineColor () const
 
void setFontFixedPitch (bool fixedPitch)
 
bool fontFixedPitch () const
 
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)
 
VerticalAlignment verticalAlignment () const
 
void setTextOutline (const QPen &pen)
 
QPen textOutline () const
 
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)
 
bool isAnchor () const
 
void setAnchorHref (const QString &value)
 
QString anchorHref () const
 
void setAnchorNames (const QStringList &names)
 
QStringList anchorNames () const
 
void setTableCellRowSpan (int tableCellRowSpan)
 
int tableCellRowSpan () const
 
void setTableCellColumnSpan (int tableCellColumnSpan)
 
int tableCellColumnSpan () const
 
- Public Member Functions inherited from QTextFormat
 QTextFormat ()
 
 QTextFormat (int type)
 
 QTextFormat (const QTextFormat &rhs)
 
QTextFormatoperator= (const QTextFormat &rhs)
 
 ~QTextFormat ()
 
void swap (QTextFormat &other)
 
void merge (const QTextFormat &other)
 
bool isValid () const
 
bool isEmpty () const
 
int type () const
 
int objectIndex () const
 
void setObjectIndex (int object)
 
QVariant property (int propertyId) const
 
void setProperty (int propertyId, const QVariant &value)
 
void clearProperty (int propertyId)
 
bool hasProperty (int propertyId) const
 
bool boolProperty (int propertyId) const
 
int intProperty (int propertyId) const
 
qreal doubleProperty (int propertyId) const
 
QString stringProperty (int propertyId) const
 
QColor colorProperty (int propertyId) const
 
QPen penProperty (int propertyId) const
 
QBrush brushProperty (int propertyId) const
 
QTextLength lengthProperty (int propertyId) const
 
QList< QTextLengthlengthVectorProperty (int propertyId) const
 
void setProperty (int propertyId, const QList< QTextLength > &lengths)
 
QMap< int, QVariantproperties () const
 
int propertyCount () const
 
void setObjectType (int type)
 
int objectType () const
 
bool isCharFormat () const
 
bool isBlockFormat () const
 
bool isListFormat () const
 
bool isFrameFormat () const
 
bool isImageFormat () const
 
bool isTableFormat () const
 
bool isTableCellFormat () const
 
QTextBlockFormat toBlockFormat () const
 
QTextCharFormat toCharFormat () const
 
QTextListFormat toListFormat () const
 
QTextTableFormat toTableFormat () const
 
QTextFrameFormat toFrameFormat () const
 
QTextImageFormat toImageFormat () const
 
QTextTableCellFormat toTableCellFormat () const
 
bool operator== (const QTextFormat &rhs) const
 
bool operator!= (const QTextFormat &rhs) const
 
 operator QVariant () const
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
Qt::LayoutDirection layoutDirection () const
 
void setBackground (const QBrush &brush)
 
QBrush background () const
 
void clearBackground ()
 
void setForeground (const QBrush &brush)
 
QBrush foreground () const
 
void clearForeground ()
 

Protected Member Functions

 QTextCharFormat (const QTextFormat &fmt)
 

Friends

class QTextFormat
 
Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &, const QTextCharFormat &)
 
Q_GUI_EXPORT QDataStreamoperator>> (QDataStream &, QTextCharFormat &)
 

Detailed Description

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.

See also
QTextFormat, QTextBlockFormat, QTextTableFormat, QTextListFormat

Definition at line 415 of file qtextformat.h.

Member Enumeration Documentation

◆ FontPropertiesInheritanceBehavior

Since
5.3

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.

See also
setFont()
Enumerator
FontPropertiesSpecifiedOnly 
FontPropertiesAll 

Definition at line 442 of file qtextformat.h.

◆ UnderlineStyle

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.

See also
Qt::PenStyle
Enumerator
NoUnderline 
SingleUnderline 
DashUnderline 
DotLine 
DashDotLine 
DashDotDotLine 
WaveUnderline 
SpellCheckUnderline 

Definition at line 427 of file qtextformat.h.

◆ VerticalAlignment

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.

Constructor & Destructor Documentation

◆ QTextCharFormat() [1/2]

QTextCharFormat::QTextCharFormat ( )

Constructs a new character format object.

Definition at line 1486 of file qtextformat.cpp.

◆ QTextCharFormat() [2/2]

QTextCharFormat::QTextCharFormat ( const QTextFormat fmt)
explicitprotected

Definition at line 1495 of file qtextformat.cpp.

Member Function Documentation

◆ anchorHref()

QString QTextCharFormat::anchorHref ( ) const
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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ anchorNames()

QStringList QTextCharFormat::anchorNames ( ) const
Since
4.3

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ baselineOffset()

qreal QTextCharFormat::baselineOffset ( ) const
inline
Since
6.0

Returns the the baseline offset in %.

See also
setBaselineOffset(), setSubScriptBaseline(), subScriptBaseline(), setSuperScriptBaseline(), superScriptBaseline()

Definition at line 590 of file qtextformat.h.

Here is the call graph for this function:

◆ font()

QFont QTextCharFormat::font ( ) const

Returns the font for this character format.

Definition at line 2183 of file qtextformat.cpp.

Here is the caller graph for this function:

◆ fontCapitalization()

Capitalization QTextCharFormat::fontCapitalization ( ) const
inline
Since
4.4

Returns the current capitalization type of the font.

Definition at line 491 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fontFamilies()

QStringList QTextCharFormat::fontFamilies ( ) const
inline

Definition at line 462 of file qtextformat.h.

◆ fontFixedPitch()

bool QTextCharFormat::fontFixedPitch ( ) const
inline

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

See also
font()

Definition at line 527 of file qtextformat.h.

Here is the call graph for this function:

◆ fontHintingPreference()

QFont::HintingPreference QTextCharFormat::fontHintingPreference ( ) const
inline
Since
4.8

Returns the hinting preference set for this text format.

See also
font(), QFont::hintingPreference()

Definition at line 549 of file qtextformat.h.

Here is the call graph for this function:

◆ fontItalic()

bool QTextCharFormat::fontItalic ( ) const
inline

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

See also
font()

Definition at line 487 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fontKerning()

bool QTextCharFormat::fontKerning ( ) const
inline
Since
4.5

Returns true if the font kerning is enabled.

See also
setFontKerning()
font()

Definition at line 556 of file qtextformat.h.

Here is the call graph for this function:

◆ fontLetterSpacing()

qreal QTextCharFormat::fontLetterSpacing ( ) const
inline
Since
4.4

Returns the current letter spacing.

See also
setFontLetterSpacing()
setFontLetterSpacingType()
fontLetterSpacingType()

Definition at line 499 of file qtextformat.h.

Here is the call graph for this function:

◆ fontLetterSpacingType()

QFont::SpacingType QTextCharFormat::fontLetterSpacingType ( ) const
inline
Since
5.0

Returns the letter spacing type of this format..

See also
setFontLetterSpacingType()
setFontLetterSpacing()
fontLetterSpacing()

Definition at line 495 of file qtextformat.h.

Here is the call graph for this function:

◆ fontOverline()

bool QTextCharFormat::fontOverline ( ) const
inline

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

See also
font()

Definition at line 512 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fontPointSize()

qreal QTextCharFormat::fontPointSize ( ) const
inline

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

See also
font()

Definition at line 478 of file qtextformat.h.

Here is the call graph for this function:

◆ fontStretch()

int QTextCharFormat::fontStretch ( ) const
inline
Since
5.0

Returns the current font stretching.

See also
setFontStretch()

Definition at line 532 of file qtextformat.h.

Here is the call graph for this function:

◆ fontStrikeOut()

bool QTextCharFormat::fontStrikeOut ( ) const
inline

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

See also
font()

Definition at line 517 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fontStyleHint()

QTextCharFormat::StyleHint QTextCharFormat::fontStyleHint ( ) const
inline
Since
4.5

Returns the font style hint.

See also
setFontStyleHint(), font()

Definition at line 539 of file qtextformat.h.

Here is the call graph for this function:

◆ fontStyleName()

QStringList QTextCharFormat::fontStyleName ( ) const
inline

Definition at line 472 of file qtextformat.h.

◆ fontStyleStrategy()

QTextCharFormat::StyleStrategy QTextCharFormat::fontStyleStrategy ( ) const
inline
Since
4.5

Returns the current font style strategy.

See also
setFontStyleStrategy()
font()

Definition at line 541 of file qtextformat.h.

Here is the call graph for this function:

◆ fontUnderline()

bool QTextCharFormat::fontUnderline ( ) const

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

See also
font()

Definition at line 1667 of file qtextformat.cpp.

Here is the call graph for this function:

◆ fontWeight()

int QTextCharFormat::fontWeight ( ) const
inline

Returns the text format's font weight.

See also
font(), QFont::Weight

Definition at line 483 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fontWordSpacing()

qreal QTextCharFormat::fontWordSpacing ( ) const
inline
Since
4.4

Returns the current word spacing value.

Definition at line 503 of file qtextformat.h.

Here is the call graph for this function:

◆ isAnchor()

bool QTextCharFormat::isAnchor ( ) const
inline

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

See also
setAnchor(), setAnchorHref(), setAnchorNames()

Definition at line 595 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValid()

bool QTextCharFormat::isValid ( ) const
inline

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

Definition at line 440 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setAnchor()

void QTextCharFormat::setAnchor ( bool  anchor)
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.

See also
isAnchor()

Definition at line 593 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setAnchorHref()

void QTextCharFormat::setAnchorHref ( const QString value)
inline

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setAnchorNames()

void QTextCharFormat::setAnchorNames ( const QStringList names)
inline
Since
4.3

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.

Here is the call graph for this function:

◆ setBaselineOffset()

void QTextCharFormat::setBaselineOffset ( qreal  baseline)
inline
Since
6.0

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.

See also
baselineOffset(), setSubScriptBaseline(), subScriptBaseline(), setSuperScriptBaseline(), superScriptBaseline()

Definition at line 588 of file qtextformat.h.

Here is the call graph for this function:

◆ setFont()

void QTextCharFormat::setFont ( const QFont font,
FontPropertiesInheritanceBehavior  behavior = FontPropertiesAll 
)
Since
5.3

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.

See also
font()

Definition at line 2127 of file qtextformat.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontCapitalization()

void QTextCharFormat::setFontCapitalization ( QFont::Capitalization  capitalization)
inline
Since
4.4

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.

See also
fontCapitalization()

Definition at line 489 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontFamilies()

void QTextCharFormat::setFontFamilies ( const QStringList families)
inline
Since
5.13

Sets the text format's font families.

See also
setFont()

Definition at line 456 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontFixedPitch()

void QTextCharFormat::setFontFixedPitch ( bool  fixedPitch)
inline

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

See also
setFont()

Definition at line 525 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontHintingPreference()

void QTextCharFormat::setFontHintingPreference ( QFont::HintingPreference  hintingPreference)
inline
Since
4.8

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

See also
setFont(), QFont::setHintingPreference()

Definition at line 544 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontItalic()

void QTextCharFormat::setFontItalic ( bool  italic)
inline

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

See also
setFont()

Definition at line 485 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontKerning()

void QTextCharFormat::setFontKerning ( bool  enable)
inline
Since
4.5

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.

See also
setFont()

Definition at line 554 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontLetterSpacing()

void QTextCharFormat::setFontLetterSpacing ( qreal  spacing)
inline
Since
4.4

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.

See also
fontLetterSpacing()
setFontLetterSpacingType()
fontLetterSpacingType()

Definition at line 497 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontLetterSpacingType()

void QTextCharFormat::setFontLetterSpacingType ( QFont::SpacingType  letterSpacingType)
inline
Since
5.0

Sets the letter spacing type of this format to letterSpacingType.

See also
fontLetterSpacingType()
setFontLetterSpacing()
fontLetterSpacing()

Definition at line 493 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontOverline()

void QTextCharFormat::setFontOverline ( bool  overline)
inline

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

See also
setFont()

Definition at line 510 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontPointSize()

void QTextCharFormat::setFontPointSize ( qreal  size)
inline

Sets the text format's font size.

See also
setFont()

Definition at line 476 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontStretch()

void QTextCharFormat::setFontStretch ( int  factor)
inline
Since
5.0

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.

See also
fontStretch()

Definition at line 530 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontStrikeOut()

void QTextCharFormat::setFontStrikeOut ( bool  strikeOut)
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.

See also
setFont()

Definition at line 515 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontStyleHint()

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

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.

See also
setFont()
QFont::setStyleHint()

Definition at line 535 of file qtextformat.h.

Here is the caller graph for this function:

◆ setFontStyleName()

void QTextCharFormat::setFontStyleName ( const QString styleName)
inline
Since
5.13

Sets the text format's font styleName.

See also
setFont(), QFont::setStyleName()

Definition at line 466 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontStyleStrategy()

void QTextCharFormat::setFontStyleStrategy ( QFont::StyleStrategy  strategy)
inline
Since
4.5

Sets the font style strategy.

See also
setFont()
QFont::setStyleStrategy()

Definition at line 537 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontUnderline()

void QTextCharFormat::setFontUnderline ( bool  underline)
inline

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

See also
setFont()

Definition at line 506 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontWeight()

void QTextCharFormat::setFontWeight ( int  weight)
inline

Sets the text format's font weight to weight.

See also
setFont(), QFont::Weight

Definition at line 481 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontWordSpacing()

void QTextCharFormat::setFontWordSpacing ( qreal  spacing)
inline
Since
4.4

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

See also
fontWordSpacing()

Definition at line 501 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSubScriptBaseline()

void QTextCharFormat::setSubScriptBaseline ( qreal  baseline)
inline
Since
6.0

Sets the subscript's base line as a % of font height to baseline. The default value is 16.67% (1/6 of height)

See also
subScriptBaseline(), setSuperScriptBaseline(), superScriptBaseline(), setBaselineOffset(), baselineOffset()

Definition at line 583 of file qtextformat.h.

Here is the call graph for this function:

◆ setSuperScriptBaseline()

void QTextCharFormat::setSuperScriptBaseline ( qreal  baseline)
inline
Since
6.0

Sets the superscript's base line as a % of font height to baseline. The default value is 50% (1/2 of height).

See also
superScriptBaseline(), setSubScriptBaseline(), subScriptBaseline(), setBaselineOffset(), baselineOffset()

Definition at line 578 of file qtextformat.h.

Here is the call graph for this function:

◆ setTableCellColumnSpan()

void QTextCharFormat::setTableCellColumnSpan ( int  tableCellColumnSpan)
inline

Definition at line 631 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTableCellRowSpan()

void QTextCharFormat::setTableCellRowSpan ( int  tableCellRowSpan)
inline

Definition at line 623 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTextOutline()

void QTextCharFormat::setTextOutline ( const QPen pen)
inline

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

Definition at line 568 of file qtextformat.h.

Here is the call graph for this function:

◆ setToolTip()

void QTextCharFormat::setToolTip ( const QString text)
inline
Since
4.3

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

Definition at line 573 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUnderlineColor()

void QTextCharFormat::setUnderlineColor ( const QColor color)
inline

Sets the color used to draw underlines, overlines and strikeouts on the characters with this format to the color specified.

See also
underlineColor()

Definition at line 520 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUnderlineStyle()

void QTextCharFormat::setUnderlineStyle ( UnderlineStyle  style)
Since
4.2

Sets the style of underlining the text to style.

Definition at line 1687 of file qtextformat.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setVerticalAlignment()

void QTextCharFormat::setVerticalAlignment ( VerticalAlignment  alignment)
inline

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

See also
verticalAlignment()

Definition at line 563 of file qtextformat.h.

Here is the call graph for this function:

◆ subScriptBaseline()

qreal QTextCharFormat::subScriptBaseline ( ) const
inline
Since
6.0

Returns the subscript's base line as a % of font height.

See also
setSubScriptBaseline(), setSuperScriptBaseline(), superScriptBaseline(), setBaselineOffset(), baselineOffset()

Definition at line 585 of file qtextformat.h.

Here is the call graph for this function:

◆ superScriptBaseline()

qreal QTextCharFormat::superScriptBaseline ( ) const
inline
Since
6.0

Returns the superscript's base line as a % of font height.

See also
setSuperScriptBaseline(), setSubScriptBaseline(), subScriptBaseline(), setBaselineOffset(), baselineOffset()

Definition at line 580 of file qtextformat.h.

Here is the call graph for this function:

◆ tableCellColumnSpan()

int QTextCharFormat::tableCellColumnSpan ( ) const
inline

Definition at line 611 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tableCellRowSpan()

int QTextCharFormat::tableCellRowSpan ( ) const
inline

Definition at line 608 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ textOutline()

QPen QTextCharFormat::textOutline ( ) const
inline

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

Definition at line 570 of file qtextformat.h.

Here is the call graph for this function:

◆ toolTip()

QString QTextCharFormat::toolTip ( ) const
inline
Since
4.3

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

Definition at line 575 of file qtextformat.h.

Here is the call graph for this function:

◆ underlineColor()

QColor QTextCharFormat::underlineColor ( ) const
inline

Returns the color used to draw underlines, overlines and strikeouts on the characters with this format.

See also
setUnderlineColor()

Definition at line 522 of file qtextformat.h.

Here is the call graph for this function:

◆ underlineStyle()

UnderlineStyle QTextCharFormat::underlineStyle ( ) const
inline
Since
4.2

Returns the style of underlining the text.

Definition at line 560 of file qtextformat.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verticalAlignment()

VerticalAlignment QTextCharFormat::verticalAlignment ( ) const
inline

Returns the vertical alignment used for characters with this format.

See also
setVerticalAlignment()

Definition at line 565 of file qtextformat.h.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator<<

Q_GUI_EXPORT QDataStream& operator<< ( QDataStream stream,
const QTextCharFormat fmt 
)
friend

Definition at line 500 of file qtextformat.cpp.

◆ operator>>

Q_GUI_EXPORT QDataStream& operator>> ( QDataStream stream,
QTextCharFormat fmt 
)
friend

Definition at line 505 of file qtextformat.cpp.

◆ QTextFormat

friend class QTextFormat
friend

Definition at line 616 of file qtextformat.h.


The documentation for this class was generated from the following files: