QIterator Struct | Qt Core | Qt 6.10.3
Description: The QIterator is a template class that allows iteration over a container in a QVariant.

- Qt 6.10
- Qt Core
- C++ Classes
- QIterator
- Qt 6.10.3 Reference Documentation

# QIterator Struct

template <typename Container> struct QIterator

The QIterator is a template class that allows iteration over a container in a QVariant. More...

Header: | `#include <QIterator>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Core)` `target_link_libraries(mytarget PRIVATE Qt6::Core)`
qmake: | `QT += core`
Since: | Qt 6.0
Inherits: | QBaseIterator

- List of all members, including inherited members

## Public Functions

| QIterator(QIterable<Container> *iterable, void *iterator)
bool | operator!=(const QIterator<Container> &other) const
QIterator<Container> | operator+(qsizetype j) const
QIterator<Container> & | operator++()
QIterator<Container> | operator++(int)
QIterator<Container> & | operator+=(qsizetype j)
QIterator<Container> | operator-(qsizetype j) const
qsizetype | operator-(const QIterator<Container> &j) const
QIterator<Container> & | operator--()
QIterator<Container> | operator--(int)
QIterator<Container> & | operator-=(qsizetype j)
bool | operator==(const QIterator<Container> &other) const

## Related Non-Members

QIterator<Container> | operator+(qsizetype j, const QIterator<Container> &k)

## Detailed Description

A QIterator can only be created by a QIterable instance, and can be used in a way similar to other stl-style iterators. Generally, QIterator should not be used directly, but through its derived classes provided by QSequentialIterable and QAssociativeIterable.

See also QIterable.

## Member Function Documentation

### `[explicit]` QIterator::QIterator(QIterable<Container> *iterable, void *iterator)

Creates an iterator from an iterable and a pointer to a native iterator.

### bool QIterator::operator!=(const QIterator<Container> &other) const

Returns `true` if other points to a different item than this iterator; otherwise returns `false`.

See also operator==().

### QIterator<Container> QIterator::operator+(qsizetype j) const

Returns an iterator to the item at j positions forward from this iterator.

See also operator-() and operator+=().

### QIterator<Container> &QIterator::operator++()

The prefix `++` operator (`++it`) advances the iterator to the next item in the container and returns an iterator to the new current item.

Calling this function on QSequentialIterable::constEnd() leads to undefined results.

See also operator--().

### QIterator<Container> QIterator::operator++(int)

The postfix `++` operator (`it++`) advances the iterator to the next item in the container and returns an iterator to the previously current item.

This is an overloaded function.

### QIterator<Container> &QIterator::operator+=(qsizetype j)

Advances the iterator by j items.

See also operator-=() and operator+().

### QIterator<Container> QIterator::operator-(qsizetype j) const

Returns an iterator to the item at j positions backward from this iterator.

If the container in the QVariant does not support bi-directional iteration, calling this function leads to undefined results.

See also operator+(), operator-=(), and QIterable::canReverseIterate().

### qsizetype QIterator::operator-(const QIterator<Container> &j) const

Returns the distance between the two iterators.

This is an overloaded function.

See also operator+(), operator-=(), and QIterable::canReverseIterate().

### QIterator<Container> &QIterator::operator--()

The prefix `--` operator (`--it`) makes the preceding item current and returns an iterator to the new current item.

Calling this function on QSequentialIterable::constBegin() leads to undefined results.

If the container in the QVariant does not support bi-directional iteration, calling this function leads to undefined results.

See also operator++() and QIterable::canReverseIterate().

### QIterator<Container> QIterator::operator--(int)

The postfix `--` operator (`it--`) makes the preceding item current and returns an iterator to the previously current item.

If the container in the QVariant does not support bi-directional iteration, calling this function leads to undefined results.

This is an overloaded function.

See also QIterable::canReverseIterate().

### QIterator<Container> &QIterator::operator-=(qsizetype j)

Makes the iterator go back by j items.

If the container in the QVariant does not support bi-directional iteration, calling this function leads to undefined results.

See also operator+=(), operator-(), and QIterable::canReverseIterate().

### bool QIterator::operator==(const QIterator<Container> &other) const

Returns `true` if other points to the same item as this iterator; otherwise returns `false`.

See also operator!=().

## Related Non-Members

### QIterator<Container> operator+(qsizetype j, const QIterator<Container> &k)

Returns an iterator to the item at j positions forward from iterator k.