QTextBlock::iterator Class
class QTextBlock::iteratorQTextBlock::iterator 类提供了一个迭代器,用于读取QTextBlock 的内容。更多内容...
- 所有成员列表(包括继承的成员)
- iterator 属于富文本处理 API 的一部分。
公共函数
| iterator() | |
| bool | atEnd() const |
| QTextFragment | fragment() const |
| bool | operator!=(const QTextBlock::iterator &other) const |
| QTextBlock::iterator & | operator++() |
| QTextBlock::iterator | operator++(int) |
| QTextBlock::iterator & | operator--() |
| QTextBlock::iterator | operator--(int) |
| bool | operator==(const QTextBlock::iterator &other) const |
详细说明
一个文本块由一系列文本片段组成。该类提供了一种遍历这些片段并读取其内容的方法。它不提供修改文本块内部结构或内容的方法。
可以通过以下方式构建迭代器并将其用于访问文本块中的片段:
QTextBlock::iterator it;
for (it = currentBlock.begin(); !(it.atEnd()); ++it) {
QTextFragment currentFragment = it.fragment();
if (currentFragment.isValid())
processFragment(currentFragment);
}另请参阅 QTextFragment 。
成员函数文档
[constexpr noexcept default] iterator::iterator()
为该文本块创建一个迭代器。
bool iterator::atEnd() const
如果当前项是文本块中的最后一项,则返回true 。
QTextFragment iterator::fragment() const
返回迭代器当前所指向的文本片段。
bool iterator::operator!=(const QTextBlock::iterator &other) const
如果该迭代器与other 迭代器不同,则返回true;否则返回false 。
QTextBlock::iterator &iterator::operator++()
前缀 ++ 运算符(++i )将迭代器向前移动到哈希表中的下一个元素,并返回指向新当前元素的迭代器。
QTextBlock::iterator iterator::operator++(int)
后缀 ++ 运算符(i++ )将迭代器向前移动到文本块中的下一个项目,并返回一个指向原当前项目的迭代器。
QTextBlock::iterator &iterator::operator--()
前缀运算符(--i )将前一个元素设为当前元素,并返回一个指向新当前元素的迭代器。
QTextBlock::iterator iterator::operator--(int)
后缀运算符(i-- )将前一个元素设为当前元素,并返回指向旧当前元素的迭代器。
bool iterator::operator==(const QTextBlock::iterator &other) const
如果该迭代器与other 迭代器相同,则返回true;否则返回false 。
© 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.