本页内容

QTextBlockGroup Class

QTextBlockGroup 类为QTextDocument 中的文本块提供了一个容器。更多内容...

头文件: #include <QTextBlockGroup>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
继承自: QTextObject
被继承者:

QTextList

注意:该类中的所有函数均为可重入的。

受保护的函数

QTextBlockGroup(QTextDocument *document)
virtual ~QTextBlockGroup()
virtual void blockFormatChanged(const QTextBlock &block)
virtual void blockInserted(const QTextBlock &block)
QList<QTextBlock> blockList() const
virtual void blockRemoved(const QTextBlock &block)

详细说明

块组可用于组织文档中的文本块。即使在编辑文本块时,它们也会维护一个属于该组文本块的最新列表。

每个组都有一个父文档,该文档在创建组时指定。

可以使用blockInserted() 将文本块插入到组中,并使用blockRemoved() 将其删除。如果文本块的格式发生了变化,则会调用blockFormatChanged()。

blockList() 返回组中块的列表。请注意,列表中的块在文档中不一定是相邻的元素;例如,多级列表中的顶级项目会被列表中较低级别的项目隔开。

另请参阅 QTextBlock 和QTextDocument 。

成员函数文档

[explicit protected] QTextBlockGroup::QTextBlockGroup(QTextDocument *document)

为给定的document 创建一个新的区块组。

警告:此 函数仅应从 `QTextDocument::createObject()` 中调用。

[virtual noexcept protected] QTextBlockGroup::~QTextBlockGroup()

删除该块组;这些块不会被删除,只是不再属于该块组了。

[virtual protected] void QTextBlockGroup::blockFormatChanged(const QTextBlock &block)

每当指定文本的block 发生变化时,都会调用此函数。该文本块是该组的成员。

基类的实现不执行任何操作。

[virtual protected] void QTextBlockGroup::blockInserted(const QTextBlock &block)

将给定的block 追加到该组末尾。

警告:若 要重写此函数,必须调用基类的实现。

[protected] QList<QTextBlock> QTextBlockGroup::blockList() const

返回一个包含该块组中所有块的列表(该列表可能为空)。

[virtual protected] void QTextBlockGroup::blockRemoved(const QTextBlock &block)

将指定的block 从组中移除;该 本身不会被删除,只是不再是该组的成员。

© 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.