On this page

QMetaSequence::Iterable::ConstIterator Class

class QMetaSequence::Iterable::ConstIterator

QMetaSequence::Iterable::ConstIterator allows iteration over a container in a QVariant. More...

This class was introduced in Qt 6.11.

Public Functions

QVariant operator*() const
int operator->() const
QVariant operator[](qsizetype n) const

Detailed Description

A QMetaSequence::Iterable::ConstIterator can only be created by a QMetaSequence::Iterable instance, and can be used in a way similar to other stl-style iterators.

QList<int> intList = {7, 11, 42};

QVariant variant = QVariant::fromValue(intList);
if (variant.canConvert<QVariantList>()) {
    QMetaSequence::Iterable iterable = variant.value<QMetaSequence::Iterable>();
    // Can use C++11 range-for:
    for (const QVariant &v : iterable) {
        qDebug() << v;
    }
    // Can use iterators:
    QMetaSequence::Iterable::const_iterator it = iterable.begin();
    const QMetaSequence::Iterable::const_iterator end = iterable.end();
    for ( ; it != end; ++it) {
        qDebug() << *it;
    }
}

Member Function Documentation

QVariant ConstIterator::operator*() const

Returns the current item, converted to a QVariant.

int ConstIterator::operator->() const

Returns the current item, converted to a QVariant::ConstPointer.

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

Returns the item offset from the current one by n, converted to a QVariant.

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