QMetaSequence::Iterable::ConstIterator Class
class QMetaSequence::Iterable::ConstIteratorQMetaSequence::Iterable::ConstIterator 允许在QVariant 中对容器进行迭代。更多内容...
该类在 Qt 6.11 中引入。
公共函数
| QVariant | operator*() const |
| int | operator->() const |
| QVariant | operator[](qsizetype n) const |
详细说明
QMetaSequence::Iterable::ConstIterator 只能由QMetaSequence::Iterable 实例创建,其使用方式与其他 STL 风格的迭代器类似。
QList<int>intList={7, 11, 42};
QVariant variant=QVariant::fromValue(intList);
if(variant.canConvert<QVariantList>()) {
QMetaSequence::Iterable iterable=variant.value<QMetaSequence::Iterable>();
// 可使用 C++11 范围 for 循环:
for(constQVariant&v: iterable) {
qDebug() << v;
}
// 可以使用迭代器:
QMetaSequence::Iterable::const_iteratorit=iterable.begin();
constQMetaSequence::Iterable::const_iteratorend=iterable.end();
for( ; it!=end;++it) {
qDebug() << *it;
}
}© 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.