QIterable Class
template <typename Container> class QIterableQIterable 是一个模板类,是QMetaSequence::Iterable 和QMetaAssociation::Iterable 的基类。更多内容...
| 头文件: | #include <QIterable> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
| 自: | Qt 6.0 |
| 被继承于: |
公共函数
| bool | canForwardIterate() const |
| bool | canInputIterate() const |
| bool | canRandomAccessIterate() const |
| bool | canReverseIterate() const |
| void | clear() |
| QConstIterator<Container> | constBegin() const |
| QConstIterator<Container> | constEnd() const |
| QIterator<Container> | mutableBegin() |
| QIterator<Container> | mutableEnd() |
| qsizetype | size() const |
详细说明
QIterable<Container> 通过QVariant 提供了一个用于遍历容器的通用接口,其中Container 是元类型描述符(QMetaSequence 或QMetaAssociation 之一),用于定义容器的迭代能力。
成员函数文档
bool QIterable::canForwardIterate() const
返回是否可以按正向遍历该容器。这对应于容器的迭代器和常量迭代器所具备的 std::forward_iterator_tag 迭代器特质。
bool QIterable::canInputIterate() const
返回该容器是否具有输入迭代器。这对应于容器的迭代器和 const_iterator 所具备的 std::input_iterator_tag 迭代器特质。
bool QIterable::canRandomAccessIterate() const
返回是否可以使用迭代器高效地跳过多个值。这对应于容器中迭代器和 const_iterator 的 std::random_access_iterator_tag 迭代器特性。
bool QIterable::canReverseIterate() const
返回是否可以反向遍历该容器。这对应于该容器的 const_iterator 所具备的 std::bidirectional_iterator_tag 迭代器特性。
void QIterable::clear()
清空容器。
QConstIterator<Container> QIterable::constBegin() const
返回表示容器起点的QConstIterator 。这可在STL风格的迭代中使用。
另请参阅 constEnd() 和mutableBegin()。
QConstIterator<Container> QIterable::constEnd() const
返回一个指向容器末尾的 Qterable::QConstIterator。该迭代器可用于 STL 风格的遍历。
另请参见 constBegin() 和mutableEnd()。
QIterator<Container> QIterable::mutableBegin()
返回表示容器起点的QIterator 对象。该对象可用于STL风格的遍历。
另请参阅 mutableEnd() 和constBegin()。
QIterator<Container> QIterable::mutableEnd()
返回一个指向容器末尾的 QMetaSequence::Iterable::iterator。该迭代器可用于 STL 风格的遍历。
另请参阅 mutableBegin() 和constEnd()。
qsizetype QIterable::size() const
返回容器中的值个数。
注意:如果 底层容器不提供原生方式来查询大小,则 该方法将通过迭代器合成该访问操作。此行为已弃用,并将在 Qt 的未来版本中移除。
© 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.