Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QTextFormat Class Reference

\reentrant More...

#include <qtextformat.h>

+ Inheritance diagram for QTextFormat:
+ Collaboration diagram for QTextFormat:

Public Types

enum  FormatType {
  InvalidFormat = -1 , BlockFormat = 1 , CharFormat = 2 , ListFormat = 3 ,
  FrameFormat = 5 , UserFormat = 100
}
 This enum describes the text item a QTextFormat object is formatting. 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 , 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 , OldFontFamily = 0x2000 , ObjectType = 0x2f00 , ListStyle = 0x3000 ,
  ListIndent = 0x3001 , ListNumberPrefix = 0x3002 , ListNumberSuffix = 0x3003 , ListStart = 0x3004 ,
  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 , ImageMaxWidth = 0x5015 , FullWidthSelection = 0x06000 , PageBreakPolicy = 0x7000 ,
  UserProperty = 0x100000
}
 This enum describes the different properties a format can have. 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 }
 

Public Member Functions

 QTextFormat ()
 Creates a new text format with an InvalidFormat.
 
 QTextFormat (int type)
 Creates a new text format of the given type.
 
 QTextFormat (const QTextFormat &rhs)
 Creates a new text format with the same attributes as the other text format.
 
QTextFormatoperator= (const QTextFormat &rhs)
 Assigns the other text format to this text format, and returns a reference to this text format.
 
 ~QTextFormat ()
 Destroys this text format.
 
void swap (QTextFormat &other)
 
void merge (const QTextFormat &other)
 Merges the other format with this format; where there are conflicts the other format takes precedence.
 
bool isValid () const
 Returns true if the format is valid (i.e.
 
bool isEmpty () const
 
int type () const
 Returns the type of this format.
 
int objectIndex () const
 Returns the index of the format object, or -1 if the format object is invalid.
 
void setObjectIndex (int object)
 Sets the format object's object index.
 
QVariant property (int propertyId) const
 Returns the property specified by the given propertyId.
 
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.
 
bool hasProperty (int propertyId) const
 Returns true if the text format has a property with the given propertyId; otherwise returns false.
 
bool boolProperty (int propertyId) const
 Returns the value of the property specified by propertyId.
 
int intProperty (int propertyId) const
 Returns the value of the property specified by propertyId.
 
qreal doubleProperty (int propertyId) const
 Returns the value of the property specified by propertyId.
 
QString stringProperty (int propertyId) const
 Returns the value of the property given by propertyId; if the property isn't of QMetaType::QString type, an empty string is returned instead.
 
QColor colorProperty (int propertyId) const
 Returns the value of the property given by propertyId; if the property isn't of QMetaType::QColor type, an invalid color is returned instead.
 
QPen penProperty (int propertyId) const
 Returns the value of the property given by propertyId; if the property isn't of QMetaType::QPen type, Qt::NoPen is returned instead.
 
QBrush brushProperty (int propertyId) const
 Returns the value of the property given by propertyId; if the property isn't of QMetaType::QBrush type, Qt::NoBrush is returned instead.
 
QTextLength lengthProperty (int propertyId) const
 Returns the value of the property given by propertyId.
 
QList< QTextLengthlengthVectorProperty (int propertyId) const
 Returns the value of the property given by propertyId.
 
void setProperty (int propertyId, const QList< QTextLength > &lengths)
 Sets the value of the property given by propertyId to value.
 
QMap< int, QVariantproperties () const
 Returns a map with all properties of this text format.
 
int propertyCount () const
 
void setObjectType (int type)
 Sets the text format's object type to type.
 
int objectType () const
 Returns the text format's object type.
 
bool isCharFormat () const
 Returns true if this text format is a CharFormat; otherwise returns false.
 
bool isBlockFormat () const
 Returns true if this text format is a BlockFormat; otherwise returns false.
 
bool isListFormat () const
 Returns true if this text format is a ListFormat; otherwise returns false.
 
bool isFrameFormat () const
 Returns true if this text format is a FrameFormat; otherwise returns false.
 
bool isImageFormat () const
 Returns true if this text format is an image format; otherwise returns false.
 
bool isTableFormat () const
 Returns true if this text format is a TableFormat; otherwise returns false.
 
bool isTableCellFormat () const
 
QTextBlockFormat toBlockFormat () const
 Returns this format as a block format.
 
QTextCharFormat toCharFormat () const
 Returns this format as a character format.
 
QTextListFormat toListFormat () const
 Returns this format as a list format.
 
QTextTableFormat toTableFormat () const
 Returns this format as a table format.
 
QTextFrameFormat toFrameFormat () const
 Returns this format as a frame format.
 
QTextImageFormat toImageFormat () const
 Returns this format as an image format.
 
QTextTableCellFormat toTableCellFormat () const
 
bool operator== (const QTextFormat &rhs) const
 Returns true if this text format is the same as the other text format.
 
bool operator!= (const QTextFormat &rhs) const
 Returns true if this text format is different from the other text format.
 
 operator QVariant () const
 Returns the text format as a QVariant.
 
void setLayoutDirection (Qt::LayoutDirection direction)
 Sets the document's layout direction to the specified direction.
 
Qt::LayoutDirection layoutDirection () const
 Returns the document's layout direction.
 
void setBackground (const QBrush &brush)
 Sets the brush use to paint the document's background to the brush specified.
 
QBrush background () const
 Returns the brush used to paint the document's background.
 
void clearBackground ()
 Clears the brush used to paint the document's background.
 
void setForeground (const QBrush &brush)
 Sets the foreground brush to the specified brush.
 
QBrush foreground () const
 Returns the brush used to render foreground details, such as text, frame outlines, and table borders.
 
void clearForeground ()
 Clears the brush used to paint the document's foreground.
 

Friends

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

Detailed Description

\reentrant

The QTextFormat class provides formatting information for a QTextDocument. \inmodule QtGui

A QTextFormat is a generic class used for describing the format of parts of a QTextDocument. The derived classes QTextCharFormat, QTextBlockFormat, QTextListFormat, and QTextTableFormat are usually more useful, and describe the formatting that is applied to specific parts of the document.

A format has a FormatType which specifies the kinds of text item it can format; e.g. a block of text, a list, a table, etc. A format also has various properties (some specific to particular format types), as described by the Property enum. Every property has a corresponding Property.

The format type is given by type(), and the format can be tested with isCharFormat(), isBlockFormat(), isListFormat(), isTableFormat(), isFrameFormat(), and isImageFormat(). If the type is determined, it can be retrieved with toCharFormat(), toBlockFormat(), toListFormat(), toTableFormat(), toFrameFormat(), and toImageFormat().

A format's properties can be set with the setProperty() functions, and retrieved with boolProperty(), intProperty(), doubleProperty(), and stringProperty() as appropriate. All the property IDs used in the format can be retrieved with allPropertyIds(). One format can be merged into another using merge().

A format's object index can be set with setObjectIndex(), and retrieved with objectIndex(). These methods can be used to associate the format with a QTextObject. It is used to represent lists, frames, and tables inside the document.

See also
{Rich Text Processing}

Definition at line 89 of file qtextformat.h.

Member Enumeration Documentation

◆ FormatType

This enum describes the text item a QTextFormat object is formatting.

\value InvalidFormat An invalid format as created by the default constructor \value BlockFormat The object formats a text block \value CharFormat The object formats a single character \value ListFormat The object formats a list \value FrameFormat The object formats a frame

\value UserFormat

See also
QTextCharFormat, QTextBlockFormat, QTextListFormat, QTextTableFormat, type()
Enumerator
InvalidFormat 
BlockFormat 
CharFormat 
ListFormat 
FrameFormat 
UserFormat 

Definition at line 93 of file qtextformat.h.

◆ ObjectTypes

This enum describes what kind of QTextObject this format is associated with.

\value NoObject \value ImageObject \value TableObject \value TableCellObject \value UserObject The first object that can be used for application-specific purposes.

See also
QTextObject, QTextTable, QTextObject::format()
Enumerator
NoObject 
ImageObject 
TableObject 
TableCellObject 
UserObject 

Definition at line 263 of file qtextformat.h.

◆ PageBreakFlag

Since
4.2

This enum describes how page breaking is performed when printing. It maps to the corresponding css properties.

\value PageBreak_Auto The page break is determined automatically depending on the available space on the current page \value PageBreak_AlwaysBefore The page is always broken before the paragraph/table \value PageBreak_AlwaysAfter A new page is always started after the paragraph/table

See also
QTextBlockFormat::pageBreakPolicy(), QTextFrameFormat::pageBreakPolicy(), PageBreakPolicy
Enumerator
PageBreak_Auto 
PageBreak_AlwaysBefore 
PageBreak_AlwaysAfter 

Definition at line 273 of file qtextformat.h.

◆ Property

This enum describes the different properties a format can have.

\value ObjectIndex The index of the formatted object. See objectIndex().

Paragraph and character properties

\value CssFloat How a frame is located relative to the surrounding text \value LayoutDirection The layout direction of the text in the document (Qt::LayoutDirection).

\value OutlinePen \value ForegroundBrush \value BackgroundBrush \value BackgroundImageUrl

Paragraph properties

\value BlockAlignment \value BlockTopMargin \value BlockBottomMargin \value BlockLeftMargin \value BlockRightMargin \value TextIndent \value TabPositions Specifies the tab positions. The tab positions are structs of QTextOption::Tab which are stored in a QList (internally, in a QList<QVariant>). \value BlockIndent \value LineHeight \value LineHeightType \value BlockNonBreakableLines \value BlockTrailingHorizontalRulerWidth The width of a horizontal ruler element. \value HeadingLevel The level of a heading, for example 1 corresponds to an HTML H1 tag; otherwise 0. This enum value has been added in Qt 5.12. \value BlockCodeFence The character that was used in the "fences" around a Markdown code block. If the code block was indented rather than fenced, the block should not have this property. This enum value has been added in Qt 5.14.

\value BlockQuoteLevel The depth of nested quoting on this block: 1 means the block is a top-level block quote. Blocks that are not block quotes should not have this property. This enum value has been added in Qt 5.14. \value BlockCodeLanguage The programming language in a preformatted or code block. Blocks that do not contain code should not have this property. This enum value has been added in Qt 5.14. \value BlockMarker The \l{QTextBlockFormat::MarkerType}{type of adornment} to be shown alongside the block. This enum value has been added in Qt 5.14.

Character properties

\value FontFamily e{This property has been deprecated.} Use QTextFormat::FontFamilies instead. \omitvalue OldFontFamily \value FontFamilies \value FontStyleName \value FontPointSize \value FontPixelSize \value FontSizeAdjustment Specifies the change in size given to the fontsize already set using FontPointSize or FontPixelSize. \value FontFixedPitch \omitvalue FontSizeIncrement \value FontWeight \value FontItalic \value FontUnderline {This property has been deprecated.} Use QTextFormat::TextUnderlineStyle instead. \value FontOverline \value FontStrikeOut \value FontCapitalization Specifies the capitalization type that is to be applied to the text. \value FontLetterSpacingType Specifies the meaning of the FontLetterSpacing property. The default is QFont::PercentageSpacing. \value FontLetterSpacing Changes the default spacing between individual letters in the font. The value is specified as a percentage or absolute value, depending on FontLetterSpacingType. The default value is 100%. \value FontWordSpacing Changes the default spacing between individual words. A positive value increases the word spacing by the corresponding pixels; a negative value decreases the spacing. \value FontStretch Corresponds to the QFont::Stretch property \value FontStyleHint Corresponds to the QFont::StyleHint property \value FontStyleStrategy Corresponds to the QFont::StyleStrategy property \value FontKerning Specifies whether the font has kerning turned on. \value FontHintingPreference Controls the use of hinting according to values of the QFont::HintingPreference enum.

\omitvalue FirstFontProperty \omitvalue LastFontProperty

\value TextUnderlineColor Specifies the color to draw underlines, overlines and strikeouts. \value TextVerticalAlignment \value TextOutline \value TextUnderlineStyle \value TextToolTip Specifies the (optional) tool tip to be displayed for a fragment of text. \value TextSuperScriptBaseline Specifies the baseline (in % of height) of superscript texts. \value TextSubScriptBaseline Specifies the baseline (in % of height) of subscript texts. \value TextBaselineOffset Specifies the baseline (in % of height) of text. A positive value moves up the text, by the corresponding %; a negative value moves it down.

\value IsAnchor \value AnchorHref \value AnchorName \omitvalue OldFontLetterSpacingType \omitvalue OldFontStretch \omitvalue OldTextUnderlineColor \value ObjectType

List properties

\value ListStyle Specifies the style used for the items in a list, described by values of the QTextListFormat::Style enum. \value ListIndent Specifies the amount of indentation used for a list. \value ListNumberPrefix Defines the text which is prepended to item numbers in numeric lists. \value ListNumberSuffix Defines the text which is appended to item numbers in numeric lists. \value [since 6.6] ListStart Defines the first value of a list.

Table and frame properties

\value FrameBorder \value FrameBorderBrush \value FrameBorderStyle See the \l{QTextFrameFormat::BorderStyle}{BorderStyle} enum. \value FrameBottomMargin \value FrameHeight \value FrameLeftMargin \value FrameMargin \value FramePadding \value FrameRightMargin \value FrameTopMargin \value FrameWidth \value TableCellSpacing \value TableCellPadding \value TableColumns \value TableColumnWidthConstraints \value TableHeaderRowCount \value TableBorderCollapse Specifies the \l QTextTableFormat::borderCollapse property.

Table cell properties

\value TableCellRowSpan \value TableCellColumnSpan \value TableCellLeftPadding \value TableCellRightPadding \value TableCellTopPadding \value TableCellBottomPadding

Table cell properties intended for use with \l QTextTableFormat::borderCollapse enabled

\value TableCellTopBorder \value TableCellBottomBorder \value TableCellLeftBorder \value TableCellRightBorder

\value TableCellTopBorderStyle \value TableCellBottomBorderStyle \value TableCellLeftBorderStyle \value TableCellRightBorderStyle

\value TableCellTopBorderBrush \value TableCellBottomBorderBrush \value TableCellLeftBorderBrush \value TableCellRightBorderBrush

Image properties

\value ImageName The filename or source of the image. \value ImageTitle The title attribute of an HTML image tag, or the quoted string that comes after the URL in a Markdown image link. This enum value has been added in Qt 5.14. \value ImageAltText The alt attribute of an HTML image tag, or the image description in a Markdown image link. This enum value has been added in Qt 5.14. \value ImageWidth \value ImageHeight \value ImageQuality \value ImageMaxWidth This enum value has been added in Qt 6.8.

Selection properties

\value FullWidthSelection When set on the characterFormat of a selection, the whole width of the text will be shown selected.

Page break properties

\value PageBreakPolicy Specifies how pages are broken. See the PageBreakFlag enum.

\value UserProperty

See also
property(), setProperty()
Enumerator
ObjectIndex 
CssFloat 
LayoutDirection 
OutlinePen 
BackgroundBrush 
ForegroundBrush 
BackgroundImageUrl 
BlockAlignment 
BlockTopMargin 
BlockBottomMargin 
BlockLeftMargin 
BlockRightMargin 
TextIndent 
TabPositions 
BlockIndent 
LineHeight 
LineHeightType 
BlockNonBreakableLines 
BlockTrailingHorizontalRulerWidth 
HeadingLevel 
BlockQuoteLevel 
BlockCodeLanguage 
BlockCodeFence 
BlockMarker 
FirstFontProperty 
FontCapitalization 
FontLetterSpacing 
FontWordSpacing 
FontStyleHint 
FontStyleStrategy 
FontKerning 
FontHintingPreference 
FontFamilies 
FontStyleName 
FontLetterSpacingType 
FontStretch 
FontPointSize 
FontSizeAdjustment 
FontSizeIncrement 
FontWeight 
FontItalic 
FontUnderline 
FontOverline 
FontStrikeOut 
FontFixedPitch 
FontPixelSize 
LastFontProperty 
TextUnderlineColor 
TextVerticalAlignment 
TextOutline 
TextUnderlineStyle 
TextToolTip 
TextSuperScriptBaseline 
TextSubScriptBaseline 
TextBaselineOffset 
IsAnchor 
AnchorHref 
AnchorName 
OldFontLetterSpacingType 
OldFontStretch 
OldTextUnderlineColor 
OldFontFamily 
ObjectType 
ListStyle 
ListIndent 
ListNumberPrefix 
ListNumberSuffix 
ListStart 
FrameBorder 
FrameMargin 
FramePadding 
FrameWidth 
FrameHeight 
FrameTopMargin 
FrameBottomMargin 
FrameLeftMargin 
FrameRightMargin 
FrameBorderBrush 
FrameBorderStyle 
TableColumns 
TableColumnWidthConstraints 
TableCellSpacing 
TableCellPadding 
TableHeaderRowCount 
TableBorderCollapse 
TableCellRowSpan 
TableCellColumnSpan 
TableCellTopPadding 
TableCellBottomPadding 
TableCellLeftPadding 
TableCellRightPadding 
TableCellTopBorder 
TableCellBottomBorder 
TableCellLeftBorder 
TableCellRightBorder 
TableCellTopBorderStyle 
TableCellBottomBorderStyle 
TableCellLeftBorderStyle 
TableCellRightBorderStyle 
TableCellTopBorderBrush 
TableCellBottomBorderBrush 
TableCellLeftBorderBrush 
TableCellRightBorderBrush 
ImageName 
ImageTitle 
ImageAltText 
ImageWidth 
ImageHeight 
ImageQuality 
ImageMaxWidth 
FullWidthSelection 
PageBreakPolicy 
UserProperty 

Definition at line 104 of file qtextformat.h.

Constructor & Destructor Documentation

◆ QTextFormat() [1/3]

QTextFormat::QTextFormat ( )

Creates a new text format with an InvalidFormat.

See also
FormatType

Definition at line 872 of file qtextformat.cpp.

◆ QTextFormat() [2/3]

QTextFormat::QTextFormat ( int type)
explicit

Creates a new text format of the given type.

See also
FormatType

Definition at line 882 of file qtextformat.cpp.

◆ QTextFormat() [3/3]

QTextFormat::QTextFormat ( const QTextFormat & rhs)

Creates a new text format with the same attributes as the other text format.

Definition at line 894 of file qtextformat.cpp.

◆ ~QTextFormat()

QTextFormat::~QTextFormat ( )

Destroys this text format.

Definition at line 923 of file qtextformat.cpp.

Member Function Documentation

◆ background()

QColor QTextFormat::background ( ) const
inline

Returns the brush used to paint the document's background.

See also
setBackground(), clearBackground(), foreground()

Definition at line 353 of file qtextformat.h.

Referenced by QQuickTextNodeEngine::addTextBlock(), QTextDocumentLayoutPrivate::drawBlock(), QTextDocumentLayoutPrivate::drawTableCell(), and QPlainTextEdit::paintEvent().

+ Here is the caller graph for this function:

◆ boolProperty()

bool QTextFormat::boolProperty ( int propertyId) const

Returns the value of the property specified by propertyId.

If the property isn't of QTextFormat::Bool type, false is returned instead.

See also
setProperty(), intProperty(), doubleProperty(), stringProperty(), colorProperty(), lengthProperty(), lengthVectorProperty(), Property

Definition at line 1042 of file qtextformat.cpp.

References QTextFormatPrivate::property(), QVariant::toBool(), and QVariant::userType().

Referenced by QTextCharFormat::fontFixedPitch(), QTextCharFormat::fontItalic(), QTextCharFormat::fontKerning(), QTextCharFormat::fontOverline(), QTextCharFormat::fontStrikeOut(), QTextCharFormat::fontUnderline(), QTextItemInt::initWithScriptItem(), and QTextCharFormat::isAnchor().

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

◆ brushProperty()

QBrush QTextFormat::brushProperty ( int propertyId) const

Returns the value of the property given by propertyId; if the property isn't of QMetaType::QBrush type, Qt::NoBrush is returned instead.

See also
setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(), lengthProperty(), lengthVectorProperty(), Property

Definition at line 1152 of file qtextformat.cpp.

References Qt::NoBrush, QTextFormatPrivate::property(), and QVariant::userType().

+ Here is the call graph for this function:

◆ clearBackground()

void QTextFormat::clearBackground ( )
inline

Clears the brush used to paint the document's background.

The default brush will be used.

See also
background(), setBackground(), clearForeground()

Definition at line 355 of file qtextformat.h.

◆ clearForeground()

void QTextFormat::clearForeground ( )
inline

Clears the brush used to paint the document's foreground.

The default brush will be used.

See also
foreground(), setForeground(), clearBackground()

Definition at line 362 of file qtextformat.h.

◆ clearProperty()

void QTextFormat::clearProperty ( int propertyId)

Clears the value of the property given by propertyId.

See also
Property

Definition at line 1246 of file qtextformat.cpp.

References QTextFormatPrivate::clearProperty().

Referenced by QTextCursor::charFormat(), formatDifference(), QTextHtmlParserNode::initializeProperties(), QTextCursor::insertBlock(), QWidgetTextControlPrivate::insertParagraphSeparator(), QTextCursor::insertText(), QTextCursorPrivate::setBlockCharFormat(), QTextCursorPrivate::setCharFormat(), QTextDocumentPrivate::setCharFormat(), QTextTableCell::setFormat(), QTextCharFormat::setTableCellColumnSpan(), QTextCharFormat::setTableCellRowSpan(), and QTextHtmlExporter::toHtml().

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

◆ colorProperty()

QColor QTextFormat::colorProperty ( int propertyId) const

Returns the value of the property given by propertyId; if the property isn't of QMetaType::QColor type, an invalid color is returned instead.

See also
setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(), lengthProperty(), lengthVectorProperty(), Property

Definition at line 1116 of file qtextformat.cpp.

References QTextFormatPrivate::property(), and QVariant::userType().

Referenced by QTextCharFormat::underlineColor().

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

◆ doubleProperty()

qreal QTextFormat::doubleProperty ( int propertyId) const

Returns the value of the property specified by propertyId.

If the property isn't of QMetaType::Double or QMetaType::Float type, 0 is returned instead.

See also
setProperty(), boolProperty(), intProperty(), stringProperty(), colorProperty(), lengthProperty(), lengthVectorProperty(), Property

Definition at line 1080 of file qtextformat.cpp.

References QTextFormatPrivate::property(), and QVariant::userType().

Referenced by QTextCharFormat::baselineOffset(), QTextFrameFormat::bottomMargin(), QTextTableCellFormat::bottomPadding(), QTextCharFormat::fontLetterSpacing(), QTextCharFormat::fontPointSize(), QTextCharFormat::fontWordSpacing(), QTextFrameFormat::leftMargin(), QTextTableCellFormat::leftPadding(), QTextBlockFormat::lineHeight(), QTextFrameFormat::rightMargin(), QTextTableCellFormat::rightPadding(), QTextCharFormat::subScriptBaseline(), QTextCharFormat::superScriptBaseline(), QTextFrameFormat::topMargin(), and QTextTableCellFormat::topPadding().

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

◆ foreground()

QBrush QTextFormat::foreground ( ) const
inline

Returns the brush used to render foreground details, such as text, frame outlines, and table borders.

See also
setForeground(), clearForeground(), background()

Definition at line 360 of file qtextformat.h.

Referenced by QQuickTextNodeEngine::addText(), QQuickTextNodeEngine::addTextBlock(), QQuickTextSelection::color(), and QTextDocumentLayoutPrivate::drawListItem().

+ Here is the caller graph for this function:

◆ hasProperty()

◆ intProperty()

int QTextFormat::intProperty ( int propertyId) const

Returns the value of the property specified by propertyId.

If the property is not of QTextFormat::Integer type, 0 is returned instead.

See also
setProperty(), boolProperty(), doubleProperty(), stringProperty(), colorProperty(), lengthProperty(), lengthVectorProperty(), Property

Definition at line 1059 of file qtextformat.cpp.

References LayoutDirection, Qt::LayoutDirectionAuto, QTextFormatPrivate::property(), QVariant::toInt(), and QVariant::userType().

Referenced by QTextDocumentLayoutPrivate::drawListItem(), QTextCharFormat::fontCapitalization(), QTextCharFormat::fontHintingPreference(), QTextCharFormat::fontLetterSpacingType(), QTextCharFormat::fontStretch(), QTextCharFormat::fontStyleHint(), QTextCharFormat::fontStyleStrategy(), QTextCharFormat::fontWeight(), QTextBlockFormat::lineHeight(), QTextCharFormat::tableCellColumnSpan(), QTextCharFormat::tableCellRowSpan(), QTextHtmlExporter::toHtml(), QTextCharFormat::underlineStyle(), and QTextCharFormat::verticalAlignment().

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

◆ isBlockFormat()

bool QTextFormat::isBlockFormat ( ) const
inline

Returns true if this text format is a BlockFormat; otherwise returns false.

Definition at line 327 of file qtextformat.h.

◆ isCharFormat()

bool QTextFormat::isCharFormat ( ) const
inline

Returns true if this text format is a CharFormat; otherwise returns false.

Definition at line 326 of file qtextformat.h.

Referenced by QTextCharFormat::isValid().

+ Here is the caller graph for this function:

◆ isEmpty()

bool QTextFormat::isEmpty ( ) const
inline
Since
5.3

Returns true if the format does not store any properties; false otherwise.

See also
propertyCount(), properties()

Definition at line 295 of file qtextformat.h.

◆ isFrameFormat()

bool QTextFormat::isFrameFormat ( ) const
inline

Returns true if this text format is a FrameFormat; otherwise returns false.

Definition at line 329 of file qtextformat.h.

◆ isImageFormat()

bool QTextFormat::isImageFormat ( ) const
inline

Returns true if this text format is an image format; otherwise returns false.

Definition at line 330 of file qtextformat.h.

Referenced by QTextOdfWriter::writeInlineCharacter().

+ Here is the caller graph for this function:

◆ isListFormat()

bool QTextFormat::isListFormat ( ) const
inline

Returns true if this text format is a ListFormat; otherwise returns false.

Definition at line 328 of file qtextformat.h.

◆ isTableCellFormat()

bool QTextFormat::isTableCellFormat ( ) const
inline
Since
4.4

Returns true if this text format is a TableCellFormat; otherwise returns false.

Definition at line 332 of file qtextformat.h.

Referenced by QTextOdfWriter::writeFormats(), and QTextOdfWriter::writeFrame().

+ Here is the caller graph for this function:

◆ isTableFormat()

bool QTextFormat::isTableFormat ( ) const
inline

Returns true if this text format is a TableFormat; otherwise returns false.

Definition at line 331 of file qtextformat.h.

Referenced by QTextOdfWriter::writeFormats().

+ Here is the caller graph for this function:

◆ isValid()

bool QTextFormat::isValid ( ) const
inline

Returns true if the format is valid (i.e.

is not InvalidFormat); otherwise returns false.

Definition at line 294 of file qtextformat.h.

◆ layoutDirection()

Qt::LayoutDirection QTextFormat::layoutDirection ( ) const
inline

Returns the document's layout direction.

See also
setLayoutDirection()

Definition at line 348 of file qtextformat.h.

References LayoutDirection.

◆ lengthProperty()

QTextLength QTextFormat::lengthProperty ( int propertyId) const

Returns the value of the property given by propertyId.

See also
setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(), colorProperty(), lengthVectorProperty(), Property

Definition at line 1168 of file qtextformat.cpp.

References QTextFormatPrivate::property().

Referenced by QTextDocumentLayoutPrivate::drawBlock().

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

◆ lengthVectorProperty()

QList< QTextLength > QTextFormat::lengthVectorProperty ( int propertyId) const

Returns the value of the property given by propertyId.

If the property isn't of QTextFormat::LengthVector type, an empty list is returned instead.

See also
setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(), colorProperty(), lengthProperty(), Property

Definition at line 1183 of file qtextformat.cpp.

References QList< T >::append(), list, QTextFormatPrivate::property(), QVariant::toList(), QVariant::userType(), and var.

+ Here is the call graph for this function:

◆ merge()

void QTextFormat::merge ( const QTextFormat & other)

Merges the other format with this format; where there are conflicts the other format takes precedence.

Definition at line 940 of file qtextformat.cpp.

References QSharedDataPointer< T >::data(), i, and other().

Referenced by QWidgetTextControlPrivate::inputMethodEvent(), and QTextDocumentPrivate::setCharFormat().

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

◆ objectIndex()

int QTextFormat::objectIndex ( ) const

Returns the index of the format object, or -1 if the format object is invalid.

See also
setObjectIndex()

Definition at line 1277 of file qtextformat.cpp.

References ObjectIndex, QTextFormatPrivate::property(), QVariant::toInt(), and QVariant::userType().

Referenced by QTextDocumentPrivate::objectForFormat().

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

◆ objectType()

int QTextFormat::objectType ( ) const
inline

Returns the text format's object type.

See also
ObjectTypes, setObjectType()

Definition at line 323 of file qtextformat.h.

Referenced by QQuickTextNodeEngine::addTextBlock().

+ Here is the caller graph for this function:

◆ operator QVariant()

QTextFormat::operator QVariant ( ) const

Returns the text format as a QVariant.

Definition at line 931 of file qtextformat.cpp.

References QVariant::fromValue().

+ Here is the call graph for this function:

◆ operator!=()

bool QTextFormat::operator!= ( const QTextFormat & rhs) const
inline

Returns true if this text format is different from the other text format.

Definition at line 343 of file qtextformat.h.

References operator==().

+ Here is the call graph for this function:

◆ operator=()

QTextFormat & QTextFormat::operator= ( const QTextFormat & rhs)

Assigns the other text format to this text format, and returns a reference to this text format.

Definition at line 905 of file qtextformat.cpp.

◆ operator==()

bool QTextFormat::operator== ( const QTextFormat & rhs) const

Returns true if this text format is the same as the other text format.

Definition at line 1360 of file qtextformat.cpp.

References QList< T >::isEmpty(), and QTextFormatPrivate::props.

+ Here is the call graph for this function:

◆ penProperty()

QPen QTextFormat::penProperty ( int propertyId) const

Returns the value of the property given by propertyId; if the property isn't of QMetaType::QPen type, Qt::NoPen is returned instead.

See also
setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(), lengthProperty(), lengthVectorProperty(), Property

Definition at line 1134 of file qtextformat.cpp.

References Qt::NoPen, QTextFormatPrivate::property(), and QVariant::userType().

Referenced by QTextCharFormat::textOutline().

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

◆ properties()

QMap< int, QVariant > QTextFormat::properties ( ) const

Returns a map with all properties of this text format.

Definition at line 1327 of file qtextformat.cpp.

References QList< T >::at(), i, QMap< Key, T >::insert(), map, QTextFormatPrivate::props, and QList< T >::size().

Referenced by formatDifference().

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

◆ property()

QVariant QTextFormat::property ( int propertyId) const

Returns the property specified by the given propertyId.

See also
Property

Definition at line 1206 of file qtextformat.cpp.

References QTextFormatPrivate::property().

Referenced by QQuickTextNodeEngine::addTextBlock(), cellEdgeData(), QTextDocumentLayoutPrivate::drawBlock(), and formatDifference().

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

◆ propertyCount()

int QTextFormat::propertyCount ( ) const
Since
4.3 Returns the number of properties stored in the format.

Definition at line 1341 of file qtextformat.cpp.

References QTextFormatPrivate::props, and QList< T >::size().

+ Here is the call graph for this function:

◆ setBackground()

void QTextFormat::setBackground ( const QBrush & brush)
inline

Sets the brush use to paint the document's background to the brush specified.

See also
background(), clearBackground(), setForeground()

Definition at line 351 of file qtextformat.h.

References setProperty.

Referenced by QTextHtmlParser::applyAttributes(), QTextHtmlParserNode::applyBackgroundImage(), MainWindow::highlightListItems(), main_textblock_formats(), and QTextEdit::setTextBackgroundColor().

+ Here is the caller graph for this function:

◆ setForeground()

void QTextFormat::setForeground ( const QBrush & brush)
inline

Sets the foreground brush to the specified brush.

The foreground brush is mostly used to render text.

See also
foreground(), clearForeground(), setBackground()

Definition at line 358 of file qtextformat.h.

References setProperty.

Referenced by QTextHtmlParser::applyAttributes(), QTextHtmlParserNode::applyForegroundImage(), main(), QQuickTextSelection::setColor(), QSyntaxHighlighter::setFormat(), QTextEdit::setTextColor(), and src_gui_text_qsyntaxhighlighter::MyHighlighter::wrapper().

+ Here is the caller graph for this function:

◆ setLayoutDirection()

void QTextFormat::setLayoutDirection ( Qt::LayoutDirection direction)
inline

Sets the document's layout direction to the specified direction.

See also
layoutDirection()

Definition at line 346 of file qtextformat.h.

References direction, LayoutDirection, and setProperty.

Referenced by QTextHtmlParser::applyAttributes(), QTextHtmlParserNode::initializeProperties(), QWidgetTextControlPrivate::keyPressEvent(), and QQuickTextControlPrivate::keyPressEvent().

+ Here is the caller graph for this function:

◆ setObjectIndex()

void QTextFormat::setObjectIndex ( int index)

Sets the format object's object index.

See also
objectIndex()

Definition at line 1294 of file qtextformat.cpp.

References QTextFormatPrivate::clearProperty(), QSharedDataPointer< T >::constData(), QTextFormatPrivate::insertProperty(), o, and ObjectIndex.

Referenced by QTextList::add(), QTextCursor::createList(), QTextTablePrivate::createTable(), QTextDocumentPrivate::insertFrame(), QTextCursor::insertImage(), and QTextDocumentPrivate::setCharFormat().

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

◆ setObjectType()

void QTextFormat::setObjectType ( int type)
inline

Sets the text format's object type to type.

See also
ObjectTypes, objectType()

Definition at line 377 of file qtextformat.h.

References ObjectType, and setProperty.

Referenced by QTextImageFormat::QTextImageFormat(), QTextTableCellFormat::QTextTableCellFormat(), QTextTableFormat::QTextTableFormat(), and QTextTableCell::format().

+ Here is the caller graph for this function:

◆ setProperty() [1/2]

void QTextFormat::setProperty ( int propertyId,
const QList< QTextLength > & value )

Sets the value of the property given by propertyId to value.

See also
lengthVectorProperty(), Property

Definition at line 1229 of file qtextformat.cpp.

References QList< T >::at(), i, QTextFormatPrivate::insertProperty(), list, QList< T >::reserve(), and QList< T >::size().

+ Here is the call graph for this function:

◆ setProperty() [2/2]

void QTextFormat::setProperty ( int propertyId,
const QVariant & value )

Sets the property specified by the propertyId to the given value.

See also
Property

Definition at line 1216 of file qtextformat.cpp.

References QTextFormatPrivate::insertProperty().

Referenced by QTextHtmlParser::applyAttributes(), QTextHtmlParserNode::applyBackgroundImage(), QTextMarkdownImporter::cbEnterBlock(), QTextMarkdownImporter::cbEnterSpan(), QTextMarkdownImporter::cbText(), QTextHtmlParserNode::initializeProperties(), QCommonStyle::styleHint(), QQC2::QCommonStyle::styleHint(), and QtWaylandClient::QWaylandTextInputMethod::text_input_method_v1_input_method_event_attribute().

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

◆ stringProperty()

QString QTextFormat::stringProperty ( int propertyId) const

Returns the value of the property given by propertyId; if the property isn't of QMetaType::QString type, an empty string is returned instead.

See also
setProperty(), boolProperty(), intProperty(), doubleProperty(), colorProperty(), lengthProperty(), lengthVectorProperty(), Property

Definition at line 1098 of file qtextformat.cpp.

References QTextFormatPrivate::property(), QVariant::toString(), and QVariant::userType().

Referenced by QWidgetTextControlPrivate::anchorForCursor(), QTextCharFormat::anchorHref(), QTextMarkdownImporter::cbText(), and QTextCharFormat::toolTip().

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

◆ swap()

void QTextFormat::swap ( QTextFormat & other)
inline
Since
5.0

Swaps this text format with other. This function is very fast and never fails.

Definition at line 289 of file qtextformat.h.

References d, and other().

+ Here is the call graph for this function:

◆ toBlockFormat()

QTextBlockFormat QTextFormat::toBlockFormat ( ) const

Returns this format as a block format.

Definition at line 980 of file qtextformat.cpp.

Referenced by QTextBlock::blockFormat(), QTextFormatCollection::blockFormat(), and QTextOdfWriter::writeFormats().

+ Here is the caller graph for this function:

◆ toCharFormat()

QTextCharFormat QTextFormat::toCharFormat ( ) const

◆ toFrameFormat()

QTextFrameFormat QTextFormat::toFrameFormat ( ) const

Returns this format as a frame format.

Definition at line 1012 of file qtextformat.cpp.

Referenced by QTextFrame::frameFormat(), and QTextOdfWriter::writeFormats().

+ Here is the caller graph for this function:

◆ toImageFormat()

QTextImageFormat QTextFormat::toImageFormat ( ) const

Returns this format as an image format.

Definition at line 1020 of file qtextformat.cpp.

Referenced by QQuickTextNodeEngine::addTextObject(), QTextImageHandler::drawObject(), QAbstractTextDocumentLayout::imageAt(), QTextFormatCollection::imageFormat(), QTextImageHandler::intrinsicSize(), QQuickTextImageHandler::intrinsicSize(), main(), QTextMarkdownWriter::writeBlock(), and QTextOdfWriter::writeInlineCharacter().

+ Here is the caller graph for this function:

◆ toListFormat()

QTextListFormat QTextFormat::toListFormat ( ) const

Returns this format as a list format.

Definition at line 996 of file qtextformat.cpp.

Referenced by QTextDocumentLayoutPrivate::blockIndent(), QTextDocumentLayoutPrivate::drawListItem(), QTextList::format(), QTextFormatCollection::listFormat(), and QTextOdfWriter::writeFormats().

+ Here is the caller graph for this function:

◆ toTableCellFormat()

QTextTableCellFormat QTextFormat::toTableCellFormat ( ) const
Since
4.4

Returns this format as a table cell format.

Definition at line 1030 of file qtextformat.cpp.

Referenced by cellEdgeData(), drawCellBorder(), and QTextOdfWriter::writeFormats().

+ Here is the caller graph for this function:

◆ toTableFormat()

QTextTableFormat QTextFormat::toTableFormat ( ) const

Returns this format as a table format.

Definition at line 1004 of file qtextformat.cpp.

Referenced by QTextTable::format(), QTextFormatCollection::tableFormat(), QTextOdfWriter::writeFormats(), and QTextOdfWriter::writeTableCellFormat().

+ Here is the caller graph for this function:

◆ type()

int QTextFormat::type ( ) const

Returns the type of this format.

See also
FormatType

Definition at line 972 of file qtextformat.cpp.

Referenced by QTextOdfWriter::writeFormats().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator<<

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

Definition at line 404 of file qtextformat.cpp.

◆ operator>>

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

Definition at line 437 of file qtextformat.cpp.

◆ QTextCharFormat

friend class QTextCharFormat
friend

Definition at line 370 of file qtextformat.h.

Referenced by toCharFormat().

◆ QTextFormatCollection

friend class QTextFormatCollection
friend

Definition at line 369 of file qtextformat.h.


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