The QSequentialIterable class is an iterable interface for a container in a QVariant. More...
Header: | #include <QSequentialIterable> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
Since: | Qt 5.2 |
Inherits: | QIterable |
BidirectionalConstIterator | |
BidirectionalIterator | |
ForwardConstIterator | |
ForwardIterator | |
InputConstIterator | |
InputIterator | |
RandomAccessConstIterator | |
RandomAccessIterator | |
const_iterator | |
iterator |
void | addValue(const QVariant &value, QSequentialIterable::Position position = Unspecified) |
QVariant | at(qsizetype idx) const |
void | removeValue(QSequentialIterable::Position position = Unspecified) |
void | set(qsizetype idx, const QVariant &value) |
This class allows several methods of accessing the values of a container held within a QVariant. An instance of QSequentialIterable can be extracted from a QVariant if it can be converted to a QVariantList.
QList<int> intList = {7, 11, 42}; QVariant variant = QVariant::fromValue(intList); if (variant.canConvert<QVariantList>()) { QSequentialIterable iterable = variant.value<QSequentialIterable>(); // Can use foreach: foreach (const QVariant &v, iterable) { qDebug() << v; } // Can use C++11 range-for: for (const QVariant &v : iterable) { qDebug() << v; } // Can use iterators: QSequentialIterable::const_iterator it = iterable.begin(); const QSequentialIterable::const_iterator end = iterable.end(); for ( ; it != end; ++it) { qDebug() << *it; } }
The container itself is not copied before iterating over it.
See also QVariant.
[alias]
QSequentialIterable::BidirectionalConstIteratorExposes a const_iterator using std::bidirectional_iterator_tag.
[alias]
QSequentialIterable::BidirectionalIteratorExposes an iterator using std::bidirectional_iterator_tag.
[alias]
QSequentialIterable::ForwardConstIteratorExposes a const_iterator using std::forward_iterator_tag.
[alias]
QSequentialIterable::ForwardIteratorExposes an iterator using std::forward_iterator_tag.
[alias]
QSequentialIterable::InputConstIteratorExposes a const_iterator using std::input_iterator_tag.
[alias]
QSequentialIterable::InputIteratorExposes an iterator using std::input_iterator_tag.
[alias]
QSequentialIterable::RandomAccessConstIteratorExposes a const_iterator using std::random_access_iterator_tag.
[alias]
QSequentialIterable::RandomAccessIteratorExposes an iterator using std::random_access_iterator_tag.
[alias]
QSequentialIterable::const_iteratorThe QSequentialIterable::const_iterator allows iteration over a container in a QVariant.
A QSequentialIterable::const_iterator can only be created by a QSequentialIterable 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>()) { QSequentialIterable iterable = variant.value<QSequentialIterable>(); // Can use foreach: foreach (const QVariant &v, iterable) { qDebug() << v; } // Can use C++11 range-for: for (const QVariant &v : iterable) { qDebug() << v; } // Can use iterators: QSequentialIterable::const_iterator it = iterable.begin(); const QSequentialIterable::const_iterator end = iterable.end(); for ( ; it != end; ++it) { qDebug() << *it; } }
[alias, since 6.0]
QSequentialIterable::iteratorThe QSequentialIterable::iterator allows iteration over a container in a QVariant.
A QSequentialIterable::iterator can only be created by a QSequentialIterable instance, and can be used in a way similar to other stl-style iterators.
This typedef was introduced in Qt 6.0.
Adds value to the container, at position, if possible.
Returns the value at position idx in the container.
Removes a value from the container, at position, if possible.
Sets the element at position idx in the container to value.