在本页

QMetaSequence::Iterable::ConstIterator Class

class QMetaSequence::Iterable::ConstIterator

QMetaSequence::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变量=QVariant::fromValue(intList);if(variant.canConvert<QVariantList>()) { QMetaSequence::Iterable iterable=variant.value<QMetaSequence::Iterable>();// 可以使用 C++11 range-for: for(constQVariant&v: iterable) {        qDebug() << v;
    }// 可以使用迭代器QMetaSequence::Iterable::const_iterator it=iterable.begin();constQMetaSequence::Iterable::const_iterator end=iterable.end();for( ; it!=end;++it) {        qDebug() << *it;
    } }

成员函数文档

QVariant ConstIterator::operator*() const

返回当前项目,并转换为QVariant

int ConstIterator::operator->() const

返回当前项目,并转换为QVariant::ConstPointer

QVariant ConstIterator::operator[](qsizetype n) const

通过n 返回与当前项目偏移的项目,并转换为QVariant

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