QTextFormat Class
QTextFormat 类为QTextDocument 提供了格式化信息。更多内容...
| 头文件: | #include <QTextFormat> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
| qmake: | QT += gui |
| 被继承者: | QTextBlockFormat、QTextCharFormat 、QTextFrameFormat ,以及QTextListFormat |
- 所有成员列表(包括继承的成员)
- QTextFormat 属于“富文本处理 API”和“隐式共享类”。
注意:该类中的所有函数均为可重入函数。
公共类型
| enum | FormatType { InvalidFormat, BlockFormat, CharFormat, ListFormat, FrameFormat, UserFormat } |
| enum | ObjectTypes { NoObject, ImageObject, TableObject, TableCellObject, UserObject } |
| enum | PageBreakFlag { PageBreak_Auto, PageBreak_AlwaysBefore, PageBreak_AlwaysAfter } |
| flags | PageBreakFlags |
| enum | Property { ObjectIndex, CssFloat, LayoutDirection, OutlinePen, ForegroundBrush, …, UserProperty } |
公共函数
| QTextFormat() | |
| QTextFormat(int type) | |
| QTextFormat(const QTextFormat &other) | |
| ~QTextFormat() | |
| QBrush | background() const |
| bool | boolProperty(int propertyId) const |
| QBrush | brushProperty(int propertyId) const |
| void | clearBackground() |
| void | clearForeground() |
| void | clearProperty(int propertyId) |
| QColor | colorProperty(int propertyId) const |
| qreal | doubleProperty(int propertyId) const |
| QBrush | foreground() const |
| bool | hasProperty(int propertyId) const |
| int | intProperty(int propertyId) const |
| bool | isBlockFormat() const |
| bool | isCharFormat() const |
| bool | isEmpty() const |
| bool | isFrameFormat() const |
| bool | isImageFormat() const |
| bool | isListFormat() const |
| bool | isTableCellFormat() const |
| bool | isTableFormat() const |
| bool | isValid() const |
| Qt::LayoutDirection | layoutDirection() const |
| QTextLength | lengthProperty(int propertyId) const |
| QList<QTextLength> | lengthVectorProperty(int propertyId) const |
| void | merge(const QTextFormat &other) |
| int | objectIndex() const |
| int | objectType() const |
| QPen | penProperty(int propertyId) const |
| QMap<int, QVariant> | properties() const |
| QVariant | property(int propertyId) const |
| int | propertyCount() const |
| void | setBackground(const QBrush &brush) |
| void | setForeground(const QBrush &brush) |
| void | setLayoutDirection(Qt::LayoutDirection direction) |
| void | setObjectIndex(int index) |
| void | setObjectType(int type) |
| void | setProperty(int propertyId, const QList<QTextLength> &value) |
| void | setProperty(int propertyId, const QVariant &value) |
| QString | stringProperty(int propertyId) const |
| void | swap(QTextFormat &other) |
| QTextBlockFormat | toBlockFormat() const |
| QTextCharFormat | toCharFormat() const |
| QTextFrameFormat | toFrameFormat() const |
| QTextImageFormat | toImageFormat() const |
| QTextListFormat | toListFormat() const |
| QTextTableCellFormat | toTableCellFormat() const |
| QTextTableFormat | toTableFormat() const |
| int | type() const |
| operator QVariant() const | |
| bool | operator!=(const QTextFormat &other) const |
| QTextFormat & | operator=(const QTextFormat &other) |
| bool | operator==(const QTextFormat &other) const |
详细说明
QTextFormat 是一个用于描述QTextDocument 中各部分格式的通用类。其派生类QTextCharFormat 、QTextBlockFormat 、QTextListFormat 和QTextTableFormat 通常更为实用,它们描述了应用于文档特定部分的格式。
每种格式都有一个“文本项类型”(FormatType ),用于指定其可格式化的文本项类型;例如:文本块、列表、表格等。格式还具有各种属性(其中部分属性仅适用于特定格式类型),这些属性由Property枚举定义。每个属性都有对应的Property成员。
格式类型由type()函数确定,可通过isCharFormat()、isBlockFormat()、isListFormat()、isTableFormat()、isFrameFormat()和isImageFormat()函数对格式进行检测。若已确定类型,则可通过toCharFormat()、toBlockFormat()、toListFormat()、toTableFormat()、toFrameFormat()和toImageFormat()函数获取该类型。
可以通过setProperty() 函数设置格式的属性,并根据需要使用boolProperty()、intProperty()、doubleProperty() 和stringProperty() 函数进行获取。所有在该格式中使用的属性 ID 均可通过 allPropertyIds() 获取。可以使用merge() 将一种格式合并到另一种格式中。
可通过setObjectIndex() 设置格式的对象索引,并通过objectIndex() 获取该索引。这些方法可用于将格式与QTextObject 关联起来。它用于表示文档中的列表、框架和表格。
另请参阅 “富文本处理”。
成员类型文档
enum QTextFormat::FormatType
此枚举描述了QTextFormat 对象正在格式化的文本项。
| 常量 | 值 | 描述 |
|---|---|---|
QTextFormat::InvalidFormat | -1 | 由默认构造函数创建的格式无效 |
QTextFormat::BlockFormat | 1 | 该对象正在对一个文本块进行格式化 |
QTextFormat::CharFormat | 2 | 该对象对单个字符进行格式化 |
QTextFormat::ListFormat | 3 | 该对象对列表进行格式化 |
QTextFormat::FrameFormat | 5 | 该对象对一个框架进行格式化 |
QTextFormat::UserFormat | 100 |
另请参阅 QTextCharFormat 、QTextBlockFormat 、QTextListFormat 、QTextTableFormat 以及type()。
enum QTextFormat::ObjectTypes
此枚举描述了该格式关联的QTextObject 类型。
| 常量 | 值 | 描述 |
|---|---|---|
QTextFormat::NoObject | 0 | |
QTextFormat::ImageObject | 1 | |
QTextFormat::TableObject | 2 | |
QTextFormat::TableCellObject | 3 | |
QTextFormat::UserObject | 0x1000 | 第一个可用于特定应用程序目的的对象。 |
另请参阅 QTextObject 、QTextTable 以及QTextObject::format()。
enum QTextFormat::PageBreakFlag
flags QTextFormat::PageBreakFlags
此枚举描述了打印时分页的方式,并映射到相应的 CSS 属性。
| 常量 | 值 | 描述 |
|---|---|---|
QTextFormat::PageBreak_Auto | 0 | 分页位置将根据当前页面的可用空间自动确定 |
QTextFormat::PageBreak_AlwaysBefore | 0x001 | 页面总是在段落/表格之前换行 |
QTextFormat::PageBreak_AlwaysAfter | 0x010 | 段落/表格之后总是开始新页面 |
PageBreakFlags 类型是QFlags<PageBreakFlag> 的 typedef。它存储 PageBreakFlag 值的按“或”运算组合。
另请参阅 QTextBlockFormat::pageBreakPolicy()、QTextFrameFormat::pageBreakPolicy() 以及PageBreakPolicy 。
enum QTextFormat::Property
此枚举描述了格式可能具有的各种属性。
| 常量 | 值 | 描述 |
|---|---|---|
QTextFormat::ObjectIndex | 0x0 | 格式化对象的索引。参见objectIndex()。 |
段落和字符属性
| 常量 | 值 | 描述 |
|---|---|---|
QTextFormat::CssFloat | 0x0800 | 框架相对于周围文本的位置方式 |
QTextFormat::LayoutDirection | 0x0801 | 文档中文本的排版方向(Qt::LayoutDirection )。 |
QTextFormat::OutlinePen | 0x810 | |
QTextFormat::ForegroundBrush | 0x821 | |
QTextFormat::BackgroundBrush | 0x820 | |
QTextFormat::BackgroundImageUrl | 0x823 |
段落属性
| 常量 | 值 | 说明 |
|---|---|---|
QTextFormat::BlockAlignment | 0x1010 | |
QTextFormat::BlockTopMargin | 0x1030 | |
QTextFormat::BlockBottomMargin | 0x1031 | |
QTextFormat::BlockLeftMargin | 0x1032 | |
QTextFormat::BlockRightMargin | 0x1033 | |
QTextFormat::TextIndent | 0x1034 | |
QTextFormat::TabPositions | 0x1035 | 指定制表符的位置。这些制表符位置是QTextOption::Tab 结构体,存储在QList 中(在内部,存储于QList<QVariant>)。 |
QTextFormat::BlockIndent | 0x1040 | |
QTextFormat::LineHeight | 0x1048 | |
QTextFormat::LineHeightType | 0x1049 | |
QTextFormat::BlockNonBreakableLines | 0x1050 | |
QTextFormat::BlockTrailingHorizontalRulerWidth | 0x1060 | 水平标尺元素的宽度。 |
QTextFormat::HeadingLevel | 0x1070 | 标题的级别,例如 1 对应 HTML H1 标签;否则为 0。此枚举值已于 Qt 5.12 中添加。 |
QTextFormat::BlockCodeFence | 0x1091 | Markdown 代码块周围“围栏”中使用的字符。如果代码块采用缩进而非围栏形式,则该代码块不应具有此属性。此枚举值自 Qt 5.14 起新增。 |
QTextFormat::BlockQuoteLevel | 0x1080 | 该代码块的嵌套引用层级:1 表示该代码块是顶级块引用。非块引用的代码块不应具有此属性。该枚举值自 Qt 5.14 起新增。 |
QTextFormat::BlockCodeLanguage | 0x1090 | 预格式化或代码块中的编程语言。不包含代码的代码块不应具有此属性。该枚举值已在 Qt 5.14 中添加。 |
QTextFormat::BlockMarker | 0x10A0 | 要与代码块一同显示的type of adornment 。该枚举值已于 Qt 5.14 中添加。 |
字符属性
| 常量 | 值 | 描述 |
|---|---|---|
QTextFormat::FontFamily | 0x2000 | e{此属性已弃用。} 请改用 QTextFormat::FontFamilies。 |
QTextFormat::FontFamilies | 0x1FE7 | |
QTextFormat::FontStyleName | 0x1FE8 | |
QTextFormat::FontPointSize | 0x2001 | |
QTextFormat::FontPixelSize | 0x2009 | |
QTextFormat::FontSizeAdjustment | 0x2002 | 指定一个整数调整值,该值将加到使用FontPointSize 或FontPixelSize 设置的基础字体大小上。 |
QTextFormat::FontFixedPitch | 0x2008 | |
QTextFormat::FontWeight | 0x2003 | |
QTextFormat::FontItalic | 0x2004 | |
QTextFormat::FontUnderline | 0x2005 | 该属性已弃用。请改用 QTextFormat::TextUnderlineStyle。 |
QTextFormat::FontOverline | 0x2006 | |
QTextFormat::FontStrikeOut | 0x2007 | |
QTextFormat::FontCapitalization | FirstFontProperty | 指定要应用于文本的大小写类型。 |
QTextFormat::FontLetterSpacingType | 0x1FE9 | 指定 FontLetterSpacing 属性的含义。默认值为QFont::PercentageSpacing 。 |
QTextFormat::FontLetterSpacing | 0x1FE1 | 更改字体中单个字母之间的默认间距。该值根据 FontLetterSpacingType 的不同,以百分比或绝对值的形式指定。默认值为 100%。 |
QTextFormat::FontWordSpacing | 0x1FE2 | 更改单词之间的默认间距。正值会按相应像素值增加单词间距;负值会减少间距。 |
QTextFormat::FontStretch | 0x1FEA | 对应于QFont::Stretch 属性 |
QTextFormat::FontStyleHint | 0x1FE3 | 对应于QFont::StyleHint 属性 |
QTextFormat::FontStyleStrategy | 0x1FE4 | 对应于QFont::StyleStrategy 属性 |
QTextFormat::FontKerning | 0x1FE5 | 指定字体是否启用了字间距调整。 |
QTextFormat::FontHintingPreference | 0x1FE6 | 根据QFont::HintingPreference 枚举的值控制提示功能的使用。 |
QTextFormat::FontFeatures | 0x2010 | [自 6.11 起] 为排版特征分配整数值。有关详细信息,请参阅QFont::setFeature()。 |
QTextFormat::FontVariableAxes | 0x2011 | [自 6.11 起] 为可变字体的可变轴分配浮点数。有关详细信息,请参阅QFont::setVariableAxis()。 |
QTextFormat::TextUnderlineColor | 0x2020 | 指定绘制下划线、上划线和删除线的颜色。 |
QTextFormat::TextVerticalAlignment | 0x2021 | 根据QTextCharFormat::VerticalAlignment 枚举的值指定文本垂直对齐类型。 |
QTextFormat::TextOutline | 0x2022 | 指定用于绘制文本轮廓的QPen 。 |
QTextFormat::TextUnderlineStyle | 0x2023 | 根据QTextCharFormat::UnderlineStyle 枚举的值指定文本下划线的样式。 |
QTextFormat::TextToolTip | 0x2024 | 指定要为文本片段显示的(可选)工具提示。 |
QTextFormat::TextSuperScriptBaseline | 0x2025 | 指定上标文本的基线(以高度的百分比表示)。 |
QTextFormat::TextSubScriptBaseline | 0x2026 | 指定下标文本的基线(以高度的百分比表示)。 |
QTextFormat::TextBaselineOffset | 0x2027 | 指定文本的基线(以高度的百分比表示)。正值会将文本向上移动相应的百分比;负值则将其向下移动。 |
QTextFormat::IsAnchor | 0x2030 | |
QTextFormat::AnchorHref | 0x2031 | |
QTextFormat::AnchorName | 0x2032 | |
QTextFormat::ObjectType | 0x2f00 |
列表属性
| 常量 | 值 | 描述 |
|---|---|---|
QTextFormat::ListStyle | 0x3000 | 指定列表项所使用的样式,由QTextListFormat::Style 枚举的值来描述。 |
QTextFormat::ListIndent | 0x3001 | 指定列表的缩进量。 |
QTextFormat::ListNumberPrefix | 0x3002 | 定义在数字列表中项目编号前添加的文本。 |
QTextFormat::ListNumberSuffix | 0x3003 | 定义在数字列表中附加到项目编号后面的文本。 |
QTextFormat::ListStart (since Qt 6.6) | 0x3004 | 定义列表的第一个值。 |
表格和框架属性
| 常量 | 值 | 说明 |
|---|---|---|
QTextFormat::FrameBorder | 0x4000 | |
QTextFormat::FrameBorderBrush | 0x4009 | |
QTextFormat::FrameBorderStyle | 0x4010 | 参见BorderStyle 枚举。 |
QTextFormat::FrameBottomMargin | 0x4006 | |
QTextFormat::FrameHeight | 0x4004 | |
QTextFormat::FrameLeftMargin | 0x4007 | |
QTextFormat::FrameMargin | 0x4001 | |
QTextFormat::FramePadding | 0x4002 | |
QTextFormat::FrameRightMargin | 0x4008 | |
QTextFormat::FrameTopMargin | 0x4005 | |
QTextFormat::FrameWidth | 0x4003 | |
QTextFormat::TableCellSpacing | 0x4102 | |
QTextFormat::TableCellPadding | 0x4103 | |
QTextFormat::TableColumns | 0x4100 | |
QTextFormat::TableColumnWidthConstraints | 0x4101 | |
QTextFormat::TableHeaderRowCount | 0x4104 | |
QTextFormat::TableBorderCollapse | 0x4105 | 指定QTextTableFormat::borderCollapse 属性。 |
表格单元格属性
| 常量 | 值 |
|---|---|
QTextFormat::TableCellRowSpan | 0x4810 |
QTextFormat::TableCellColumnSpan | 0x4811 |
QTextFormat::TableCellLeftPadding | 0x4814 |
QTextFormat::TableCellRightPadding | 0x4815 |
QTextFormat::TableCellTopPadding | 0x4812 |
QTextFormat::TableCellBottomPadding | 0x4813 |
在启用QTextTableFormat::borderCollapse 时适用的表格单元格属性
| 常量 | 值 |
|---|---|
QTextFormat::TableCellTopBorder | 0x4816 |
QTextFormat::TableCellBottomBorder | 0x4817 |
QTextFormat::TableCellLeftBorder | 0x4818 |
QTextFormat::TableCellRightBorder | 0x4819 |
QTextFormat::TableCellTopBorderStyle | 0x481a |
QTextFormat::TableCellBottomBorderStyle | 0x481b |
QTextFormat::TableCellLeftBorderStyle | 0x481c |
QTextFormat::TableCellRightBorderStyle | 0x481d |
QTextFormat::TableCellTopBorderBrush | 0x481e |
QTextFormat::TableCellBottomBorderBrush | 0x481f |
QTextFormat::TableCellLeftBorderBrush | 0x4820 |
QTextFormat::TableCellRightBorderBrush | 0x4821 |
图像属性
| 常量 | 值 | 描述 |
|---|---|---|
QTextFormat::ImageName | 0x5000 | 图像的文件名或来源。 |
QTextFormat::ImageTitle | 0x5001 | HTML 图片标签的 title 属性,或 Markdown 图片链接中 URL 后面的带引号字符串。该枚举值已于 Qt 5.14 中添加。 |
QTextFormat::ImageAltText | 0x5002 | HTML 图片标签的 alt 属性,或 Markdown 图片链接中的图片描述。该枚举值在 Qt 5.14 中新增。 |
QTextFormat::ImageWidth | 0x5010 | |
QTextFormat::ImageHeight | 0x5011 | |
QTextFormat::ImageQuality | 0x5014 | |
QTextFormat::ImageMaxWidth | 0x5015 | 该枚举值已于 Qt 6.8 中添加。 |
选择属性
| 常量 | 值 | 描述 |
|---|---|---|
QTextFormat::FullWidthSelection | 0x06000 | 当在选区的 characterFormat 上设置此属性时,文本的整个宽度都会显示为被选中状态。 |
分页属性
| 常量 | 值 | 说明 |
|---|---|---|
QTextFormat::PageBreakPolicy | 0x7000 | 指定分页方式。请参阅PageBreakFlag 枚举。 |
QTextFormat::UserProperty | 0x100000 |
另请参阅 property() 和setProperty()。
成员函数文档
QTextFormat::QTextFormat()
使用InvalidFormat 创建一个新的文本格式。
另请参阅 FormatType 。
[explicit] QTextFormat::QTextFormat(int type)
根据给定的type 创建一种新的文本格式。
另请参阅 FormatType 。
QTextFormat::QTextFormat(const QTextFormat &other)
创建一个新的文本格式,其属性与“other ”文本格式相同。
[noexcept] QTextFormat::~QTextFormat()
删除此文本格式。
QBrush QTextFormat::background() const
返回用于绘制文档背景的画笔。
另请参阅 setBackground()、clearBackground() 和foreground()。
bool QTextFormat::boolProperty(int propertyId) const
返回由propertyId 指定的属性的值。如果该属性不是 QTextFormat::Bool 类型,则返回 false。
另请参阅 setProperty()、intProperty()、doubleProperty()、stringProperty()、colorProperty()、lengthProperty()、lengthVectorProperty() 以及Property 。
QBrush QTextFormat::brushProperty(int propertyId) const
返回由propertyId 指定的属性的值;如果该属性不是QMetaType::QBrush 类型,则返回Qt::NoBrush 。
另请参阅 setProperty()、boolProperty()、intProperty()、doubleProperty()、stringProperty()、lengthProperty()、lengthVectorProperty() 以及Property 。
void QTextFormat::clearBackground()
清除用于绘制文档背景的画笔。将改用默认画笔。
另请参阅 background()、setBackground()、以及clearForeground()。
void QTextFormat::clearForeground()
清除用于绘制文档前景的画笔。将使用默认画笔。
另请参阅 foreground()、setForeground(),以及clearBackground()。
void QTextFormat::clearProperty(int propertyId)
清除由propertyId
另请参阅 Property 。
QColor QTextFormat::colorProperty(int propertyId) const
返回由propertyId 指定的属性的值;如果该属性不是QMetaType::QColor 类型,则返回一个无效的颜色值。
另请参阅 setProperty()、boolProperty()、intProperty()、doubleProperty()、stringProperty()、lengthProperty()、lengthVectorProperty() 以及Property 。
qreal QTextFormat::doubleProperty(int propertyId) const
返回由propertyId 指定的属性的值。如果该属性不是QMetaType::Double 或QMetaType::Float 类型,则返回 0。
另请参阅 setProperty()、boolProperty()、intProperty()、stringProperty()、colorProperty()、lengthProperty()、lengthVectorProperty() 以及Property 。
QBrush QTextFormat::foreground() const
返回用于渲染前景细节(如文本、框架轮廓和表格边框)的画笔。
另请参阅 setForeground()、clearForeground() 和background()。
bool QTextFormat::hasProperty(int propertyId) const
如果文本格式中存在具有给定propertyId 的属性,则返回true ;否则返回false 。
另请参阅 properties() 和Property 。
int QTextFormat::intProperty(int propertyId) const
返回由propertyId 指定的属性的值。如果该属性不是 QTextFormat::Integer 类型,则返回 0。
另请参见 setProperty()、boolProperty()、doubleProperty()、stringProperty()、colorProperty()、lengthProperty()、lengthVectorProperty() 以及Property 。
bool QTextFormat::isBlockFormat() const
如果该文本格式为BlockFormat ,则返回true ;否则返回false 。
bool QTextFormat::isCharFormat() const
如果该文本格式为CharFormat ,则返回true ;否则返回false 。
bool QTextFormat::isEmpty() const
如果该格式未存储任何属性,则返回 true;否则返回 false。
另请参阅 propertyCount() 和properties()。
bool QTextFormat::isFrameFormat() const
如果该文本格式为FrameFormat ,则返回true ;否则返回false 。
bool QTextFormat::isImageFormat() const
如果该文本格式为图像格式,则返回true ;否则返回false 。
bool QTextFormat::isListFormat() const
如果该文本格式为ListFormat ,则返回true ;否则返回false 。
bool QTextFormat::isTableCellFormat() const
如果该文本格式为TableCellFormat ,则返回true ;否则返回false 。
bool QTextFormat::isTableFormat() const
如果该文本格式为TableFormat ,则返回true ;否则返回false 。
bool QTextFormat::isValid() const
如果格式有效(即不是InvalidFormat ),则返回true ;否则返回false 。
Qt::LayoutDirection QTextFormat::layoutDirection() const
返回文档的排版方向。
另请参阅 ` setLayoutDirection()`。
QTextLength QTextFormat::lengthProperty(int propertyId) const
返回由propertyId 指定的属性的值。
另请参阅 setProperty()、boolProperty()、intProperty()、doubleProperty()、stringProperty()、colorProperty()、lengthVectorProperty() 以及Property 。
QList<QTextLength> QTextFormat::lengthVectorProperty(int propertyId) const
返回由propertyId 指定的属性的值。如果该属性不是 QTextFormat::LengthVector 类型,则返回一个空列表。
另请参阅 setProperty()、boolProperty()、intProperty()、doubleProperty()、stringProperty()、colorProperty()、lengthProperty() 以及Property 。
void QTextFormat::merge(const QTextFormat &other)
将other 格式与本格式合并;若出现冲突,则以other 格式为准。
int QTextFormat::objectIndex() const
返回格式对象的索引;如果格式对象无效,则返回 -1。
另请参阅 setObjectIndex()。
int QTextFormat::objectType() const
返回文本格式的对象类型。
另请参阅 ` ObjectTypes ` 和 `setObjectType()`。
QPen QTextFormat::penProperty(int propertyId) const
返回由propertyId 指定的属性的值;如果该属性不是QMetaType::QPen 类型,则返回Qt::NoPen 。
另请参阅 setProperty()、boolProperty()、intProperty()、doubleProperty()、stringProperty()、lengthProperty()、lengthVectorProperty() 以及Property 。
QMap<int, QVariant> QTextFormat::properties() const
返回一个包含该文本格式所有属性的映射。
QVariant QTextFormat::property(int propertyId) const
返回由给定的propertyId 指定的属性。
另请参阅 setProperty() 和Property 。
int QTextFormat::propertyCount() const
返回以该格式存储的属性数量。
void QTextFormat::setBackground(const QBrush &brush)
将用于绘制文档背景的画笔设置为指定的brush 。
另请参阅 background()、clearBackground() 和setForeground()。
void QTextFormat::setForeground(const QBrush &brush)
将前景色笔刷设置为指定的brush 。前景色笔刷主要用于渲染文本。
另请参阅 foreground()、clearForeground() 和setBackground()。
void QTextFormat::setLayoutDirection(Qt::LayoutDirection direction)
将文档的排版方向设置为指定的direction 。
另请参阅 layoutDirection()。
void QTextFormat::setObjectIndex(int index)
设置格式对象的index 属性。
另请参阅 objectIndex()。
void QTextFormat::setObjectType(int type)
将文本格式的对象类型设置为type 。
另请参阅 ObjectTypes 和objectType()。
void QTextFormat::setProperty(int propertyId, const QList<QTextLength> &value)
将由propertyId 指定的属性值设置为value 。
另请参阅 property()、lengthVectorProperty() 以及Property 。
void QTextFormat::setProperty(int propertyId, const QVariant &value)
将propertyId 指定的属性设置为给定的value 。
另请参阅 Property 。
QString QTextFormat::stringProperty(int propertyId) const
返回由propertyId 指定的属性的值;如果该属性不是QMetaType::QString 类型,则返回空字符串。
另请参见 setProperty()、boolProperty()、intProperty()、doubleProperty()、colorProperty()、lengthProperty()、lengthVectorProperty(),以及Property 。
void QTextFormat::swap(QTextFormat &other)
将此文本格式转换为other 。该操作速度极快,且从不会失败。
QTextBlockFormat QTextFormat::toBlockFormat() const
将此格式作为块格式返回。
QTextCharFormat QTextFormat::toCharFormat() const
将此格式作为字符格式返回。
QTextFrameFormat QTextFormat::toFrameFormat() const
将此格式作为帧格式返回。
QTextImageFormat QTextFormat::toImageFormat() const
将此格式作为图像格式返回。
QTextListFormat QTextFormat::toListFormat() const
将该格式以列表形式返回。
QTextTableCellFormat QTextFormat::toTableCellFormat() const
将此格式作为表格单元格格式返回。
QTextTableFormat QTextFormat::toTableFormat() const
将此格式以表格形式返回。
int QTextFormat::type() const
返回此格式的类型。
另请参阅 FormatType 。
QTextFormat::operator QVariant() const
将文本格式作为QVariant
bool QTextFormat::operator!=(const QTextFormat &other) const
如果该文本格式与other 文本格式不同,则返回true 。
QTextFormat &QTextFormat::operator=(const QTextFormat &other)
将other 文本格式分配给此文本格式,并返回对此文本格式的引用。
bool QTextFormat::operator==(const QTextFormat &other) const
如果该文本格式与other 文本格式相同,则返回true 。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.