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