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() 。
© 2025 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.