QTextObject Class
QTextObject 类是各种对象的基类,这些对象可以将QTextDocument 的各个部分组合在一起。更多内容...
| 头文件: | #include <QTextObject> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
| qmake: | QT += gui |
| 继承自: | QObject |
| 继承自: |
- 所有成员列表(包括继承的成员)
- QTextObject 是富文本处理 API 的一部分。
注意:该类中的所有函数均为可重入的。
公共函数
| QTextDocument * | document() const |
| QTextFormat | format() const |
| int | formatIndex() const |
| int | objectIndex() const |
受保护函数
| QTextObject(QTextDocument *document) | |
| virtual | ~QTextObject() |
| void | setFormat(const QTextFormat &format) |
详细说明
常见的分组文本对象包括列表(QTextList )、框架(QTextFrame )和表格(QTextTable )。每个文本对象都关联着一个format()和document()。
文本对象基本上分为两类:一类用于块(块格式),另一类用于字符(字符格式)。第一类继承自QTextBlockGroup ,第二类继承自QTextFrame 。
您很少需要直接使用该类。在创建自定义文本对象时,您还需要重写QTextDocument::createObject() 方法,该方法作为创建文本对象的工厂方法。
另请参阅 QTextDocument 。
成员函数文档
[explicit protected] QTextObject::QTextObject(QTextDocument *document)
为给定的document 创建一个新的QTextObject。
警告: 切勿直接调用此 函数,而应仅通过QTextDocument::createObject()调用。
[virtual noexcept protected] QTextObject::~QTextObject()
销毁文本对象。
警告:文本 对象由文档拥有,因此您绝不应自行销毁它们。
QTextDocument *QTextObject::document() const
返回该对象所属的文档。
另请参阅 format()。
QTextFormat QTextObject::format() const
返回文本对象的格式。
int QTextObject::formatIndex() const
返回该对象的格式在文档内部格式列表中的索引。
另请参阅 QTextDocument::allFormats()。
int QTextObject::objectIndex() const
返回该对象的对象索引。该方法可与QTextFormat::setObjectIndex() 配合使用。
[protected] void QTextObject::setFormat(const QTextFormat &format)
设置文本对象的format 。
另请参阅 format()。
© 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.