Qt 4.8
Public Types | Public Functions | Protected Functions | Friends | List of all members
QTextCharFormat Class Reference

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

#include <qtextformat.h>

Inheritance diagram for QTextCharFormat:
QTextFormat QTextImageFormat QTextTableCellFormat

Public Types

enum  UnderlineStyle {
  NoUnderline, SingleUnderline, DashUnderline, DotLine,
  DashDotLine, DashDotDotLine, WaveUnderline, SpellCheckUnderline
}
 This enum describes the different ways drawing underlined text. More...
 
enum  VerticalAlignment {
  AlignNormal = 0, AlignSuperScript, AlignSubScript, AlignMiddle,
  AlignTop, AlignBottom, AlignBaseline
}
 This enum describes the ways that adjacent characters can be vertically aligned. More...
 
- Public Types inherited from QTextFormat
enum  FormatType {
  InvalidFormat = -1, BlockFormat = 1, CharFormat = 2, ListFormat = 3,
  TableFormat = 4, FrameFormat = 5, UserFormat = 100
}
 This enum describes the text item a QTextFormat object is formatting. More...
 
enum  ObjectTypes {
  NoObject, ImageObject, TableObject, TableCellObject,
  UserObject = 0x1000
}
 This enum describes what kind of QTextObject this format is associated with. More...
 
enum  PageBreakFlag { PageBreak_Auto = 0, PageBreak_AlwaysBefore = 0x001, PageBreak_AlwaysAfter = 0x010 }
 This enum describes how page breaking is performed when printing. More...
 
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, FirstFontProperty = 0x1FE0,
  FontCapitalization = FirstFontProperty, FontLetterSpacing = 0x1FE1, FontWordSpacing = 0x1FE2, FontStyleHint = 0x1FE3,
  FontStyleStrategy = 0x1FE4, FontKerning = 0x1FE5, FontHintingPreference = 0x1FE6, FontFamily = 0x2000,
  FontPointSize = 0x2001, FontSizeAdjustment = 0x2002, FontSizeIncrement = FontSizeAdjustment, FontWeight = 0x2003,
  FontItalic = 0x2004, FontUnderline = 0x2005, FontOverline = 0x2006, FontStrikeOut = 0x2007,
  FontFixedPitch = 0x2008, FontPixelSize = 0x2009, LastFontProperty = FontPixelSize, TextUnderlineColor = 0x2010,
  TextVerticalAlignment = 0x2021, TextOutline = 0x2022, TextUnderlineStyle = 0x2023, TextToolTip = 0x2024,
  IsAnchor = 0x2030, AnchorHref = 0x2031, AnchorName = 0x2032, 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,
  TableCellRowSpan = 0x4810, TableCellColumnSpan = 0x4811, TableCellTopPadding = 0x4812, TableCellBottomPadding = 0x4813,
  TableCellLeftPadding = 0x4814, TableCellRightPadding = 0x4815, ImageName = 0x5000, ImageWidth = 0x5010,
  ImageHeight = 0x5011, FullWidthSelection = 0x06000, PageBreakPolicy = 0x7000, UserProperty = 0x100000
}
 This enum describes the different properties a format can have. More...
 

Public Functions

QString anchorHref () const
 Returns the text format's hypertext link, or an empty string if none has been set. More...
 
QString anchorName () const
 This function is deprecated. More...
 
QStringList anchorNames () const
 Returns the anchor names associated with this text format, or an empty string list if none has been set. More...
 
QFont font () const
 Returns the font for this character format. More...
 
QFont::Capitalization fontCapitalization () const
 Returns the current capitalization type of the font. More...
 
QString fontFamily () const
 Returns the text format's font family. More...
 
bool fontFixedPitch () const
 Returns true if the text format's font is fixed pitch; otherwise returns false. More...
 
QFont::HintingPreference fontHintingPreference () const
 Returns the hinting preference set for this text format. More...
 
bool fontItalic () const
 Returns true if the text format's font is italic; otherwise returns false. More...
 
bool fontKerning () const
 Returns true if the font kerning is enabled. More...
 
qreal fontLetterSpacing () const
 Returns the current letter spacing percentage. More...
 
bool fontOverline () const
 Returns true if the text format's font is overlined; otherwise returns false. More...
 
qreal fontPointSize () const
 Returns the font size used to display text in this format. More...
 
bool fontStrikeOut () const
 Returns true if the text format's font is struck out (has a horizontal line drawn through it); otherwise returns false. More...
 
QFont::StyleHint fontStyleHint () const
 Returns the font style hint. More...
 
QFont::StyleStrategy fontStyleStrategy () const
 Returns the current font style strategy. More...
 
bool fontUnderline () const
 Returns true if the text format's font is underlined; otherwise returns false. More...
 
int fontWeight () const
 Returns the text format's font weight. More...
 
qreal fontWordSpacing () const
 Returns the current word spacing value. More...
 
bool isAnchor () const
 Returns true if the text is formatted as an anchor; otherwise returns false. More...
 
bool isValid () const
 Returns true if this character format is valid; otherwise returns false. More...
 
 QTextCharFormat ()
 Constructs a new character format object. More...
 
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. More...
 
void setAnchorHref (const QString &value)
 Sets the hypertext link for the text format to the given value. More...
 
void setAnchorName (const QString &name)
 This function is deprecated. More...
 
void setAnchorNames (const QStringList &names)
 Sets the text format's anchor names. More...
 
void setFont (const QFont &font)
 Sets the text format's font. More...
 
void setFontCapitalization (QFont::Capitalization capitalization)
 Sets the capitalization of the text that apppears in this font to capitalization. More...
 
void setFontFamily (const QString &family)
 Sets the text format's font family. More...
 
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. More...
 
void setFontHintingPreference (QFont::HintingPreference hintingPreference)
 Sets the hinting preference of the text format's font to be hintingPreference. More...
 
void setFontItalic (bool italic)
 If italic is true, sets the text format's font to be italic; otherwise the font will be non-italic. More...
 
void setFontKerning (bool enable)
 Enables kerning for this font if enable is true; otherwise disables it. More...
 
void setFontLetterSpacing (qreal spacing)
 Sets the letter spacing of this format to the given spacing, in percent. More...
 
void setFontOverline (bool overline)
 If overline is true, sets the text format's font to be overlined; otherwise the font is displayed non-overlined. More...
 
void setFontPointSize (qreal size)
 Sets the text format's font size. More...
 
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. More...
 
void setFontStyleHint (QFont::StyleHint hint, QFont::StyleStrategy strategy=QFont::PreferDefault)
 Sets the font style hint and strategy. More...
 
void setFontStyleStrategy (QFont::StyleStrategy strategy)
 Sets the font style strategy. More...
 
void setFontUnderline (bool underline)
 If underline is true, sets the text format's font to be underlined; otherwise it is displayed non-underlined. More...
 
void setFontWeight (int weight)
 Sets the text format's font weight to weight. More...
 
void setFontWordSpacing (qreal spacing)
 Sets the word spacing of this format to the given spacing, in pixels. More...
 
void setTableCellColumnSpan (int tableCellColumnSpan)
 If this character format is applied to characters in a table cell, the cell will span tableCellColumnSpan columns. More...
 
void setTableCellRowSpan (int tableCellRowSpan)
 If this character format is applied to characters in a table cell, the cell will span tableCellRowSpan rows. More...
 
void setTextOutline (const QPen &pen)
 Sets the pen used to draw the outlines of characters to the given pen. More...
 
void setToolTip (const QString &tip)
 Sets the tool tip for a fragment of text to the given text. More...
 
void setUnderlineColor (const QColor &color)
 Sets the underline color used for the characters with this format to the color specified. More...
 
void setUnderlineStyle (UnderlineStyle style)
 Sets the style of underlining the text to style. More...
 
void setVerticalAlignment (VerticalAlignment alignment)
 Sets the vertical alignment used for the characters with this format to the alignment specified. More...
 
int tableCellColumnSpan () const
 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. More...
 
int tableCellRowSpan () const
 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. More...
 
QPen textOutline () const
 Returns the pen used to draw the outlines of characters in this format. More...
 
QString toolTip () const
 Returns the tool tip that is displayed for a fragment of text. More...
 
QColor underlineColor () const
 Returns the color used to underline the characters with this format. More...
 
UnderlineStyle underlineStyle () const
 Returns the style of underlining the text. More...
 
VerticalAlignment verticalAlignment () const
 Returns the vertical alignment used for characters with this format. More...
 
- Public Functions inherited from QTextFormat
QBrush background () const
 Returns the brush used to paint the document's background. More...
 
bool boolProperty (int propertyId) const
 Returns the value of the property specified by propertyId. More...
 
QBrush brushProperty (int propertyId) const
 Returns the value of the property given by propertyId; if the property isn't of QVariant::Brush type, Qt::NoBrush is returned instead. More...
 
void clearBackground ()
 Clears the brush used to paint the document's background. More...
 
void clearForeground ()
 Clears the brush used to paint the document's foreground. More...
 
void clearProperty (int propertyId)
 Clears the value of the property given by propertyId. More...
 
QColor colorProperty (int propertyId) const
 Returns the value of the property given by propertyId; if the property isn't of QVariant::Color type, an invalid color is returned instead. More...
 
qreal doubleProperty (int propertyId) const
 Returns the value of the property specified by propertyId. More...
 
QBrush foreground () const
 Returns the brush used to render foreground details, such as text, frame outlines, and table borders. More...
 
bool hasProperty (int propertyId) const
 Returns true if the text format has a property with the given propertyId; otherwise returns false. More...
 
int intProperty (int propertyId) const
 Returns the value of the property specified by propertyId. More...
 
bool isBlockFormat () const
 Returns true if this text format is a BlockFormat; otherwise returns false. More...
 
bool isCharFormat () const
 Returns true if this text format is a CharFormat; otherwise returns false. More...
 
bool isFrameFormat () const
 Returns true if this text format is a FrameFormat; otherwise returns false. More...
 
bool isImageFormat () const
 Returns true if this text format is an image format; otherwise returns false. More...
 
bool isListFormat () const
 Returns true if this text format is a ListFormat; otherwise returns false. More...
 
bool isTableCellFormat () const
 Returns true if this text format is a TableCellFormat; otherwise returns false. More...
 
bool isTableFormat () const
 Returns true if this text format is a TableFormat; otherwise returns false. More...
 
bool isValid () const
 Returns true if the format is valid (i. More...
 
Qt::LayoutDirection layoutDirection () const
 Returns the document's layout direction. More...
 
QTextLength lengthProperty (int propertyId) const
 Returns the value of the property given by propertyId. More...
 
QVector< QTextLengthlengthVectorProperty (int propertyId) const
 Returns the value of the property given by propertyId. More...
 
void merge (const QTextFormat &other)
 Merges the other format with this format; where there are conflicts the other format takes precedence. More...
 
int objectIndex () const
 Returns the index of the format object, or -1 if the format object is invalid. More...
 
int objectType () const
 Returns the text format's object type. More...
 
 operator QVariant () const
 Returns the text format as a QVariant. More...
 
bool operator!= (const QTextFormat &rhs) const
 Returns true if this text format is different from the other text format. More...
 
QTextFormatoperator= (const QTextFormat &rhs)
 Assigns the other text format to this text format, and returns a reference to this text format. More...
 
bool operator== (const QTextFormat &rhs) const
 Returns true if this text format is the same as the other text format. More...
 
QPen penProperty (int propertyId) const
 Returns the value of the property given by propertyId; if the property isn't of QVariant::Pen type, Qt::NoPen is returned instead. More...
 
QMap< int, QVariantproperties () const
 Returns a map with all properties of this text format. More...
 
QVariant property (int propertyId) const
 Returns the property specified by the given propertyId. More...
 
int propertyCount () const
 Returns the number of properties stored in the format. More...
 
 QTextFormat ()
 Creates a new text format with an InvalidFormat. More...
 
 QTextFormat (int type)
 Creates a new text format of the given type. More...
 
 QTextFormat (const QTextFormat &rhs)
 Creates a new text format with the same attributes as the other text format. More...
 
void setBackground (const QBrush &brush)
 Sets the brush use to paint the document's background to the brush specified. More...
 
void setForeground (const QBrush &brush)
 Sets the foreground brush to the specified brush. More...
 
void setLayoutDirection (Qt::LayoutDirection direction)
 Sets the document's layout direction to the specified direction. More...
 
void setObjectIndex (int object)
 Sets the format object's object index. More...
 
void setObjectType (int type)
 Sets the text format's object type to type. More...
 
void setProperty (int propertyId, const QVariant &value)
 Sets the property specified by the propertyId to the given value. More...
 
void setProperty (int propertyId, const QVector< QTextLength > &lengths)
 Sets the value of the property given by propertyId to value. More...
 
QString stringProperty (int propertyId) const
 Returns the value of the property given by propertyId; if the property isn't of QVariant::String type, an empty string is returned instead. More...
 
QTextBlockFormat toBlockFormat () const
 Returns this format as a block format. More...
 
QTextCharFormat toCharFormat () const
 Returns this format as a character format. More...
 
QTextFrameFormat toFrameFormat () const
 Returns this format as a frame format. More...
 
QTextImageFormat toImageFormat () const
 Returns this format as an image format. More...
 
QTextListFormat toListFormat () const
 Returns this format as a list format. More...
 
QTextTableCellFormat toTableCellFormat () const
 Returns this format as a table cell format. More...
 
QTextTableFormat toTableFormat () const
 Returns this format as a table format. More...
 
int type () const
 Returns the type of this format. More...
 
 ~QTextFormat ()
 Destroys this text format. More...
 

Protected Functions

 QTextCharFormat (const QTextFormat &fmt)
 Creates a new character format with the same attributes as the given text format. More...
 

Friends

class QTextFormat
 

Detailed Description

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

Note
This class or function is 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. setFontFamily() 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 372 of file qtextformat.h.

Enumerations

◆ UnderlineStyle

This enum describes the different ways drawing underlined text.

  • NoUnderline Text is draw without any underlining decoration.
  • SingleUnderline A line is drawn using Qt::SolidLine.
  • DashUnderline Dashes are drawn using Qt::DashLine.
  • DotLine Dots are drawn using Qt::DotLine;
  • DashDotLine Dashs and dots are drawn using Qt::DashDotLine.
  • DashDotDotLine Underlines draw drawn using Qt::DashDotDotLine.
  • WaveUnderline The text is underlined using a wave shaped line.
  • SpellCheckUnderline The underline is drawn depending on the QStyle::SH_SpellCeckUnderlineStyle style hint of the QApplication style. By default this is mapped to WaveUnderline, on Mac OS X it is mapped to DashDotLine.
See also
Qt::PenStyle
Enumerator
NoUnderline 
SingleUnderline 
DashUnderline 
DotLine 
DashDotLine 
DashDotDotLine 
WaveUnderline 
SpellCheckUnderline 

Definition at line 384 of file qtextformat.h.

◆ VerticalAlignment

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

  • AlignNormal Adjacent characters are positioned in the standard way for text in the writing system in use.
  • AlignSuperScript Characters are placed above the base line for normal text.
  • AlignSubScript Characters are placed below the base line for normal text.
  • AlignMiddle The center of the object is vertically aligned with the base line. Currently, this is only implemented for inline objects.
  • AlignBottom The bottom edge of the object is vertically aligned with the base line.
  • AlignTop The top edge of the object is vertically aligned with the base line.
  • AlignBaseline The base lines of the characters are aligned.
Enumerator
AlignNormal 
AlignSuperScript 
AlignSubScript 
AlignMiddle 
AlignTop 
AlignBottom 
AlignBaseline 

Definition at line 375 of file qtextformat.h.

Constructors and Destructors

◆ QTextCharFormat() [1/2]

QTextCharFormat::QTextCharFormat ( )

Constructs a new character format object.

Definition at line 1416 of file qtextformat.cpp.

Referenced by tableCellColumnSpan().

1416 : QTextFormat(CharFormat) {}
QTextFormat()
Creates a new text format with an InvalidFormat.

◆ QTextCharFormat() [2/2]

QTextCharFormat::QTextCharFormat ( const QTextFormat other)
explicitprotected

Creates a new character format with the same attributes as the given text format.

Warning
This function is not part of the public interface.

Definition at line 1428 of file qtextformat.cpp.

1429  : QTextFormat(fmt)
1430 {
1431 }
QTextFormat()
Creates a new text format with an InvalidFormat.

Functions

◆ 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 506 of file qtextformat.h.

Referenced by QTextControlPrivate::activateLinkUnderCursor(), QAbstractTextDocumentLayout::anchorAt(), QPlainTextEdit::anchorAt(), QPdfEnginePrivate::drawTextItem(), QTextHtmlExporter::emitFragment(), QTextControl::findNextPrevAnchor(), QTextBrowser::keyPressEvent(), QPlainTextEdit::keyPressEvent(), and QTextEdit::keyPressEvent().

507  { return stringProperty(AnchorHref); }
QString stringProperty(int propertyId) const
Returns the value of the property given by propertyId; if the property isn&#39;t of QVariant::String type...

◆ anchorName()

QString QTextCharFormat::anchorName ( ) const

This function is deprecated.

Use anchorNames() instead.

Returns the anchor name associated with this text format, or an empty string if none has been set. If the anchor name is set, text with this format can be the destination of a hypertext link.

Definition at line 1964 of file qtextformat.cpp.

Referenced by QTextHtmlExporter::emitFragment(), QTextHtmlImporter::import(), and setAnchorName().

1965 {
1966  QVariant prop = property(AnchorName);
1967  if (prop.userType() == QVariant::StringList)
1968  return prop.toStringList().value(0);
1969  else if (prop.userType() != QVariant::String)
1970  return QString();
1971  return prop.toString();
1972 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
The QString class provides a Unicode character string.
Definition: qstring.h:83
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
Definition: qvariant.cpp:2259
T value(int i) const
Returns the value at index position i in the list.
Definition: qlist.h:661
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
QVariant property(int propertyId) const
Returns the property specified by the given propertyId.

◆ anchorNames()

QStringList QTextCharFormat::anchorNames ( ) const

Returns the anchor names associated with this text format, or an empty string list if none has been set.

Since
4.3

If the anchor names are set, text with this format can be the destination of a hypertext link.

Definition at line 1985 of file qtextformat.cpp.

Referenced by QTextControl::anchorPosition(), and setAnchorNames().

1986 {
1987  QVariant prop = property(AnchorName);
1988  if (prop.userType() == QVariant::StringList)
1989  return prop.toStringList();
1990  else if (prop.userType() != QVariant::String)
1991  return QStringList();
1992  return QStringList(prop.toString());
1993 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
Definition: qvariant.cpp:2259
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
QVariant property(int propertyId) const
Returns the property specified by the given propertyId.

◆ font()

QFont QTextCharFormat::font ( ) const

Returns the font for this character format.

Definition at line 2124 of file qtextformat.cpp.

Referenced by QTextEditPrivate::_q_currentCharFormatChanged(), QAccessibleTextWidget::attributes(), QCalendarModel::data(), QTextDocumentLayoutPrivate::drawListItem(), QTextEngine::font(), QTextEngine::fontEngine(), isValid(), QPlainTextDocumentLayout::layoutBlock(), QTextDocumentLayoutPrivate::layoutBlock(), QTextDocumentLayout::resizeInlineObject(), and QScriptLine::setDefaultHeight().

2125 {
2126  return d ? d->font() : QFont();
2127 }
const QFont & font() const
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
QSharedDataPointer< QTextFormatPrivate > d
Definition: qtextformat.h:358

◆ fontCapitalization()

Capitalization QTextCharFormat::fontCapitalization ( ) const
inline

Returns the current capitalization type of the font.

Since
4.4

Definition at line 421 of file qtextformat.h.

Referenced by QTextHtmlExporter::emitCharFormatStyle(), and QTextOdfWriter::writeCharacterFormat().

422  { return static_cast<QFont::Capitalization>(intProperty(FontCapitalization)); }
Capitalization
Rendering option for text this font applies to.
Definition: qfont.h:129
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ fontFamily()

QString QTextCharFormat::fontFamily ( ) const
inline

Returns the text format's font family.

See also
font()

Definition at line 403 of file qtextformat.h.

Referenced by QAccessibleTextWidget::attributes(), QTextHtmlExporter::emitCharFormatStyle(), QTextHtmlExporter::toHtml(), and QTextOdfWriter::writeCharacterFormat().

404  { return stringProperty(FontFamily); }
QString stringProperty(int propertyId) const
Returns the value of the property given by propertyId; if the property isn&#39;t of QVariant::String type...

◆ 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 453 of file qtextformat.h.

454  { return boolProperty(FontFixedPitch); }
bool boolProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ fontHintingPreference()

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

Returns the hinting preference set for this text format.

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

Definition at line 470 of file qtextformat.h.

471  {
473  }
HintingPreference
This enum describes the different levels of hinting that can be applied to glyphs to improve legibili...
Definition: qfont.h:96
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ 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 417 of file qtextformat.h.

Referenced by QTextHtmlExporter::emitCharFormatStyle(), QTextHtmlExporter::toHtml(), and QTextOdfWriter::writeCharacterFormat().

418  { return boolProperty(FontItalic); }
bool boolProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ fontKerning()

bool QTextCharFormat::fontKerning ( ) const
inline

Returns true if the font kerning is enabled.

Since
4.5
See also
setFontKerning()
font()

Definition at line 477 of file qtextformat.h.

478  { return boolProperty(FontKerning); }
bool boolProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ fontLetterSpacing()

qreal QTextCharFormat::fontLetterSpacing ( ) const
inline

Returns the current letter spacing percentage.

Since
4.4

Definition at line 425 of file qtextformat.h.

Referenced by QTextOdfWriter::writeCharacterFormat().

426  { return doubleProperty(FontLetterSpacing); }
qreal doubleProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ 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 438 of file qtextformat.h.

Referenced by QTextHtmlExporter::emitCharFormatStyle(), and QTextItemInt::initWithScriptItem().

439  { return boolProperty(FontOverline); }
bool boolProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ fontPointSize()

qreal QTextCharFormat::fontPointSize ( ) const
inline

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

See also
font()

Definition at line 408 of file qtextformat.h.

Referenced by QAccessibleTextWidget::attributes(), QTextHtmlExporter::emitCharFormatStyle(), QTextHtmlExporter::toHtml(), and QTextOdfWriter::writeCharacterFormat().

409  { return doubleProperty(FontPointSize); }
qreal doubleProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ 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 443 of file qtextformat.h.

Referenced by QTextHtmlExporter::emitCharFormatStyle(), QTextItemInt::initWithScriptItem(), and QTextOdfWriter::writeCharacterFormat().

444  { return boolProperty(FontStrikeOut); }
bool boolProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ fontStyleHint()

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

Returns the font style hint.

Since
4.5
See also
setFontStyleHint(), font()

Definition at line 460 of file qtextformat.h.

461  { return static_cast<QFont::StyleHint>(intProperty(FontStyleHint)); }
StyleHint
Style hints are used by the font matching algorithm to find an appropriate default family if a select...
Definition: qfont.h:69
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ fontStyleStrategy()

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

Returns the current font style strategy.

Since
4.5
See also
setFontStyleStrategy()
font()

Definition at line 462 of file qtextformat.h.

463  { return static_cast<QFont::StyleStrategy>(intProperty(FontStyleStrategy)); }
StyleStrategy
The style strategy tells the font matching algorithm what type of fonts should be used to find an app...
Definition: qfont.h:81
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ fontUnderline()

bool QTextCharFormat::fontUnderline ( ) const

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

See also
font()

Definition at line 1566 of file qtextformat.cpp.

Referenced by QTextHtmlExporter::emitCharFormatStyle(), setFontUnderline(), and QTextOdfWriter::writeCharacterFormat().

1567 {
1569  return underlineStyle() == SingleUnderline;
1570  return boolProperty(FontUnderline);
1571 }
bool hasProperty(int propertyId) const
Returns true if the text format has a property with the given propertyId; otherwise returns false...
UnderlineStyle underlineStyle() const
Returns the style of underlining the text.
Definition: qtextformat.h:481
bool boolProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ fontWeight()

int QTextCharFormat::fontWeight ( ) const
inline

Returns the text format's font weight.

See also
font(), QFont::Weight

Definition at line 413 of file qtextformat.h.

Referenced by QAccessibleTextWidget::attributes(), QTextHtmlExporter::emitCharFormatStyle(), QTextHtmlExporter::toHtml(), and QTextOdfWriter::writeCharacterFormat().

414  { int weight = intProperty(FontWeight); if (weight == 0) weight = QFont::Normal; return weight; }
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ fontWordSpacing()

qreal QTextCharFormat::fontWordSpacing ( ) const
inline

Returns the current word spacing value.

Since
4.4

Definition at line 429 of file qtextformat.h.

Referenced by QTextHtmlExporter::emitCharFormatStyle(), and QTextOdfWriter::writeCharacterFormat().

430  { return doubleProperty(FontWordSpacing); }
qreal doubleProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ 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 501 of file qtextformat.h.

Referenced by QTextControlPrivate::anchorForCursor(), QTextControl::anchorPosition(), QPdfEnginePrivate::drawTextItem(), QTextHtmlExporter::emitFragment(), QTextControl::findNextPrevAnchor(), and QTextHtmlImporter::import().

502  { return boolProperty(IsAnchor); }
bool boolProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ isValid()

bool QTextCharFormat::isValid ( ) const
inline

◆ 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 499 of file qtextformat.h.

Referenced by QTextHtmlImporter::appendBlock(), QTextHtmlImporter::appendNodeText(), QTextHtmlParser::applyAttributes(), and QTextHtmlParserNode::initializeProperties().

500  { setProperty(IsAnchor, anchor); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ 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 504 of file qtextformat.h.

Referenced by QTextHtmlParser::applyAttributes().

505  { setProperty(AnchorHref, value); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setAnchorName()

void QTextCharFormat::setAnchorName ( const QString name)
inline

This function is deprecated.

Use setAnchorNames() instead.

Sets the text format's anchor name. 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 509 of file qtextformat.h.

Referenced by QTextHtmlParser::applyAttributes().

510  { setAnchorNames(QStringList(name)); }
void setAnchorNames(const QStringList &names)
Sets the text format&#39;s anchor names.
Definition: qtextformat.h:513
The QStringList class provides a list of strings.
Definition: qstringlist.h:66

◆ setAnchorNames()

void QTextCharFormat::setAnchorNames ( const QStringList names)
inline

Sets the text format's anchor names.

Since
4.3

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 513 of file qtextformat.h.

Referenced by QTextHtmlImporter::appendBlock(), QTextHtmlImporter::appendNodeText(), and setAnchorName().

514  { setProperty(AnchorName, names); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setFont()

void QTextCharFormat::setFont ( const QFont font)

Sets the text format's font.

Definition at line 2093 of file qtextformat.cpp.

Referenced by QSvgText::draw(), QCalendarModel::formatForCell(), isValid(), QTextHtmlExporter::QTextHtmlExporter(), QTextEdit::setCurrentFont(), and QSyntaxHighlighter::setFormat().

2094 {
2095  setFontFamily(font.family());
2096 
2097  const qreal pointSize = font.pointSizeF();
2098  if (pointSize > 0) {
2099  setFontPointSize(pointSize);
2100  } else {
2101  const int pixelSize = font.pixelSize();
2102  if (pixelSize > 0)
2104  }
2105 
2106  setFontWeight(font.weight());
2107  setFontItalic(font.italic());
2109  setFontOverline(font.overline());
2110  setFontStrikeOut(font.strikeOut());
2111  setFontFixedPitch(font.fixedPitch());
2116  setFontStyleHint(font.styleHint());
2118  setFontKerning(font.kerning());
2119 }
void setFontKerning(bool enable)
Enables kerning for this font if enable is true; otherwise disables it.
Definition: qtextformat.h:475
void setFontItalic(bool italic)
If italic is true, sets the text format&#39;s font to be italic; otherwise the font will be non-italic...
Definition: qtextformat.h:415
double qreal
Definition: qglobal.h:1193
void setFontStrikeOut(bool strikeOut)
If strikeOut is true, sets the text format&#39;s font with strike-out enabled (with a horizontal line thr...
Definition: qtextformat.h:441
bool underline() const
Returns true if underline has been set; otherwise returns false.
Definition: qfont.cpp:1320
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.
int pixelSize() const
Returns the pixel size of the font if it was set with setPixelSize().
Definition: qfont.cpp:1178
void setFontOverline(bool overline)
If overline is true, sets the text format&#39;s font to be overlined; otherwise the font is displayed non...
Definition: qtextformat.h:436
void setFontStyleStrategy(QFont::StyleStrategy strategy)
Sets the font style strategy.
Definition: qtextformat.h:458
Capitalization capitalization() const
Returns the current capitalization type of the font.
Definition: qfont.cpp:1819
void setFontFixedPitch(bool fixedPitch)
If fixedPitch is true, sets the text format&#39;s font to be fixed pitch; otherwise a non-fixed pitch fon...
Definition: qtextformat.h:451
bool kerning() const
Returns true if kerning should be used when drawing text with this font.
Definition: qfont.cpp:1416
void setFontWeight(int weight)
Sets the text format&#39;s font weight to weight.
Definition: qtextformat.h:411
qreal pointSizeF() const
Returns the point size of the font.
Definition: qfont.cpp:1142
static float pixelSize(const QFontDef &request, int dpi)
Definition: qfont_win.cpp:80
bool overline() const
Returns true if overline has been set; otherwise returns false.
Definition: qfont.cpp:1344
void setFontCapitalization(QFont::Capitalization capitalization)
Sets the capitalization of the text that apppears in this font to capitalization. ...
Definition: qtextformat.h:419
void setFontLetterSpacing(qreal spacing)
Sets the letter spacing of this format to the given spacing, in percent.
Definition: qtextformat.h:423
SpacingType letterSpacingType() const
Returns the spacing type used for letter spacing.
Definition: qfont.cpp:1721
void setFontPointSize(qreal size)
Sets the text format&#39;s font size.
Definition: qtextformat.h:406
qreal wordSpacing() const
Returns the word spacing for the font.
Definition: qfont.cpp:1735
bool fixedPitch() const
Returns true if fixed pitch has been set; otherwise returns false.
Definition: qfont.cpp:1391
QString family() const
Returns the requested font family name, i.e.
Definition: qfont.cpp:906
void setFontFamily(const QString &family)
Sets the text format&#39;s font family.
Definition: qtextformat.h:401
int weight() const
Returns the weight of the font which is one of the enumerated values from QFont::Weight.
Definition: qfont.cpp:1248
void setFontStyleHint(QFont::StyleHint hint, QFont::StyleStrategy strategy=QFont::PreferDefault)
Sets the font style hint and strategy.
Definition: qtextformat.h:456
void setFontWordSpacing(qreal spacing)
Sets the word spacing of this format to the given spacing, in pixels.
Definition: qtextformat.h:427
bool italic() const
Returns true if the style() of the font is not QFont::StyleNormal.
Definition: qfont.h:355
StyleStrategy styleStrategy() const
Returns the StyleStrategy.
Definition: qfont.cpp:1447
bool strikeOut() const
Returns true if strikeout has been set; otherwise returns false.
Definition: qfont.cpp:1367
StyleHint styleHint() const
Returns the StyleHint.
Definition: qfont.cpp:1460
void setUnderlineStyle(UnderlineStyle style)
Sets the style of underlining the text to style.
static float pointSize(const QFontDef &fd, int dpi)
Definition: qfont_win.cpp:90
qreal letterSpacing() const
Returns the letter spacing for the font.
Definition: qfont.cpp:1677

◆ setFontCapitalization()

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

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

Since
4.4

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

See also
fontCapitalization()

Definition at line 419 of file qtextformat.h.

Referenced by QTextHtmlParserNode::applyCssDeclarations(), and setFont().

420  { setProperty(FontCapitalization, capitalization); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setFontFamily()

void QTextCharFormat::setFontFamily ( const QString family)
inline

Sets the text format's font family.

See also
setFont()

Definition at line 401 of file qtextformat.h.

Referenced by QTextHtmlParser::applyAttributes(), QTextHtmlParserNode::applyCssDeclarations(), QTextHtmlParserNode::initializeProperties(), setFont(), and QTextEdit::setFontFamily().

402  { setProperty(FontFamily, family); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ 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 451 of file qtextformat.h.

Referenced by QTextHtmlParserNode::initializeProperties(), and setFont().

452  { setProperty(FontFixedPitch, fixedPitch); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setFontHintingPreference()

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

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

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

Definition at line 465 of file qtextformat.h.

466  {
467  setProperty(FontHintingPreference, hintingPreference);
468  }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ 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 415 of file qtextformat.h.

Referenced by QTextHtmlParserNode::applyCssDeclarations(), QTextHtmlParserNode::initializeProperties(), QDeclarativeStyledTextPrivate::parseTag(), QScriptSyntaxHighlighter::QScriptSyntaxHighlighter(), setFont(), and QTextEdit::setFontItalic().

416  { setProperty(FontItalic, italic); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setFontKerning()

void QTextCharFormat::setFontKerning ( bool  enable)
inline

Enables kerning for this font if enable is true; otherwise disables it.

Since
4.5

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 475 of file qtextformat.h.

Referenced by setFont().

476  { setProperty(FontKerning, enable); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setFontLetterSpacing()

void QTextCharFormat::setFontLetterSpacing ( qreal  spacing)
inline

Sets the letter spacing of this format to the given spacing, in percent.

Since
4.4

A value of 100 indicates default spacing; a value of 200 doubles the amount of space a letter takes.

See also
fontLetterSpacing()

Definition at line 423 of file qtextformat.h.

Referenced by setFont().

424  { setProperty(FontLetterSpacing, spacing); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ 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 436 of file qtextformat.h.

Referenced by QTextHtmlParserNode::applyCssDeclarations(), and setFont().

437  { setProperty(FontOverline, overline); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setFontPointSize()

void QTextCharFormat::setFontPointSize ( qreal  size)
inline

Sets the text format's font size.

See also
setFont()

Definition at line 406 of file qtextformat.h.

Referenced by QTextHtmlParserNode::applyCssDeclarations(), QDeclarativeStyledTextPrivate::parseFontAttributes(), setFont(), and QTextEdit::setFontPointSize().

407  { setProperty(FontPointSize, size); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ 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 441 of file qtextformat.h.

Referenced by QTextHtmlParserNode::applyCssDeclarations(), QTextHtmlParserNode::initializeProperties(), and setFont().

442  { setProperty(FontStrikeOut, strikeOut); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setFontStyleHint()

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

Sets the font style hint and strategy.

Since
4.5

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 456 of file qtextformat.h.

Referenced by setFont().

void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setFontStyleStrategy()

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

Sets the font style strategy.

Since
4.5
See also
setFont()
QFont::setStyleStrategy()

Definition at line 458 of file qtextformat.h.

Referenced by setFont().

459  { setProperty(FontStyleStrategy, strategy); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ 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 432 of file qtextformat.h.

Referenced by QMacInputContext::globalEventProcessor(), QTextControlPrivate::inputMethodEvent(), QLabel::paintEvent(), QLineControl::processInputMethodEvent(), qt_mac_compose_format(), QBBInputContext::setComposingText(), and QTextEdit::setFontUnderline().

void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setFontWeight()

void QTextCharFormat::setFontWeight ( int  weight)
inline

Sets the text format's font weight to weight.

See also
setFont(), QFont::Weight

Definition at line 411 of file qtextformat.h.

Referenced by QTextHtmlParserNode::applyCssDeclarations(), QTextHtmlParserNode::initializeProperties(), QDeclarativeStyledTextPrivate::parseTag(), setFont(), and QTextEdit::setFontWeight().

412  { if (weight == QFont::Normal) weight = 0; setProperty(FontWeight, weight); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setFontWordSpacing()

void QTextCharFormat::setFontWordSpacing ( qreal  spacing)
inline

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

Since
4.4
See also
fontWordSpacing()

Definition at line 427 of file qtextformat.h.

Referenced by setFont().

428  { setProperty(FontWordSpacing, spacing); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setTableCellColumnSpan()

void QTextCharFormat::setTableCellColumnSpan ( int  tableCellColumnSpan)
inline

If this character format is applied to characters in a table cell, the cell will span tableCellColumnSpan columns.

Warning
This function is not part of the public interface.

Definition at line 537 of file qtextformat.h.

Referenced by QTextCopyHelper::copy(), QTextTable::insertColumns(), QTextTable::mergeCells(), QTextTableCell::setFormat(), QTextTable::splitCell(), and tableCellRowSpan().

538 {
539  if (_tableCellColumnSpan <= 1)
540  clearProperty(TableCellColumnSpan); // the getter will return 1 here.
541  else
542  setProperty(TableCellColumnSpan, _tableCellColumnSpan);
543 }
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.

◆ setTableCellRowSpan()

void QTextCharFormat::setTableCellRowSpan ( int  tableCellRowSpan)
inline

If this character format is applied to characters in a table cell, the cell will span tableCellRowSpan rows.

Warning
This function is not part of the public interface.

Definition at line 529 of file qtextformat.h.

Referenced by QTextCopyHelper::copy(), QTextTable::insertColumns(), QTextTable::insertRows(), QTextTable::mergeCells(), setAnchorNames(), QTextTableCell::setFormat(), and QTextTable::splitCell().

530 {
531  if (_tableCellRowSpan <= 1)
532  clearProperty(TableCellRowSpan); // the getter will return 1 here.
533  else
534  setProperty(TableCellRowSpan, _tableCellRowSpan);
535 }
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.

◆ 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 489 of file qtextformat.h.

Referenced by QSvgText::draw(), and QGraphicsSimpleTextItem::paint().

490  { setProperty(TextOutline, pen); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setToolTip()

void QTextCharFormat::setToolTip ( const QString text)
inline

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

Since
4.3

Definition at line 494 of file qtextformat.h.

Referenced by QTextHtmlParser::applyAttributes().

495  { setProperty(TextToolTip, tip); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setUnderlineColor()

void QTextCharFormat::setUnderlineColor ( const QColor color)
inline

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

See also
underlineColor()

Definition at line 446 of file qtextformat.h.

Referenced by QMacInputContext::globalEventProcessor().

447  { setProperty(TextUnderlineColor, color); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setUnderlineStyle()

void QTextCharFormat::setUnderlineStyle ( UnderlineStyle  style)

Sets the style of underlining the text to style.

Since
4.2

Definition at line 1592 of file qtextformat.cpp.

Referenced by QTextHtmlParserNode::applyCssDeclarations(), fontKerning(), QTextHtmlParserNode::initializeProperties(), QTextControlPrivate::inputMethodEvent(), QLineControl::processInputMethodEvent(), setFont(), and QInputContext::standardFormat().

1593 {
1595  // for compatibility
1597 }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ 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 484 of file qtextformat.h.

Referenced by QTextHtmlParser::applyAttributes(), QTextHtmlParserNode::applyCssDeclarations(), QTextHtmlExporter::emitTable(), and QTextHtmlParserNode::initializeProperties().

485  { setProperty(TextVerticalAlignment, alignment); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ tableCellColumnSpan()

int QTextCharFormat::tableCellColumnSpan ( ) const
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.

Warning
This function is not part of the public interface.

Definition at line 521 of file qtextformat.h.

Referenced by QTextTableCell::columnSpan(), QTextTable::mergeCells(), QTextTable::removeColumns(), QTextTableCell::setFormat(), QTextTable::splitCell(), tableCellRowSpan(), and QTextTablePrivate::update().

522  { int s = intProperty(TableCellColumnSpan); if (s == 0) s = 1; return s; }
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ tableCellRowSpan()

int QTextCharFormat::tableCellRowSpan ( ) const
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.

Warning
This function is not part of the public interface.

Definition at line 518 of file qtextformat.h.

Referenced by QTextTable::mergeCells(), QTextTable::removeRows(), QTextTableCell::rowSpan(), setAnchorNames(), QTextTableCell::setFormat(), QTextTable::splitCell(), and QTextTablePrivate::update().

519  { int s = intProperty(TableCellRowSpan); if (s == 0) s = 1; return s; }
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ textOutline()

QPen QTextCharFormat::textOutline ( ) const
inline

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

Definition at line 491 of file qtextformat.h.

Referenced by QTextLine::draw().

492  { return penProperty(TextOutline); }
QPen penProperty(int propertyId) const
Returns the value of the property given by propertyId; if the property isn&#39;t of QVariant::Pen type...

◆ toolTip()

QString QTextCharFormat::toolTip ( ) const
inline

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

Since
4.3

Definition at line 496 of file qtextformat.h.

Referenced by QCalendarModel::data().

497  { return stringProperty(TextToolTip); }
QString stringProperty(int propertyId) const
Returns the value of the property given by propertyId; if the property isn&#39;t of QVariant::String type...

◆ underlineColor()

QColor QTextCharFormat::underlineColor ( ) const
inline

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

See also
setUnderlineColor()

Definition at line 448 of file qtextformat.h.

Referenced by drawTextItemDecoration(), and QTextOdfWriter::writeCharacterFormat().

449  { return colorProperty(TextUnderlineColor); }
QColor colorProperty(int propertyId) const
Returns the value of the property given by propertyId; if the property isn&#39;t of QVariant::Color type...

◆ underlineStyle()

UnderlineStyle QTextCharFormat::underlineStyle ( ) const
inline

Returns the style of underlining the text.

Since
4.2

Definition at line 481 of file qtextformat.h.

Referenced by fontUnderline(), QTextItemInt::initWithScriptItem(), and QTextOdfWriter::writeCharacterFormat().

482  { return static_cast<UnderlineStyle>(intProperty(TextUnderlineStyle)); }
UnderlineStyle
This enum describes the different ways drawing underlined text.
Definition: qtextformat.h:384
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ verticalAlignment()

VerticalAlignment QTextCharFormat::verticalAlignment ( ) const
inline

Returns the vertical alignment used for characters with this format.

See also
setVerticalAlignment()

Definition at line 486 of file qtextformat.h.

Referenced by QAccessibleTextWidget::attributes(), QTextLine::draw(), QTextHtmlExporter::emitCharFormatStyle(), QTextHtmlExporter::emitFragment(), QTextHtmlExporter::emitTable(), QTextEngine::font(), QTextEngine::fontEngine(), QTextDocumentLayoutPrivate::layoutTable(), QTextDocumentLayout::resizeInlineObject(), QTextOdfWriter::writeCharacterFormat(), and QTextOdfWriter::writeTableCellFormat().

487  { return static_cast<VerticalAlignment>(intProperty(TextVerticalAlignment)); }
VerticalAlignment
This enum describes the ways that adjacent characters can be vertically aligned.
Definition: qtextformat.h:375
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.

Friends and Related Functions

◆ QTextFormat

friend class QTextFormat
friend

Definition at line 526 of file qtextformat.h.


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