The QAssociativeIterable::const_iterator allows iteration over a container in a QVariant . 更多...
头: | #include <const_iterator> |
qmake: | QT += core |
Since: | Qt 5.2 |
const_iterator (const const_iterator & other ) | |
~const_iterator () | |
const QVariant | key () const |
const QVariant | value () const |
bool | operator!= (const const_iterator & other ) const |
const QVariant | operator* () const |
const_iterator | operator+ (int j ) const |
const_iterator & | operator++ () |
const_iterator | operator++ ( int ) |
const_iterator & | operator+= (int j ) |
const_iterator | operator- (int j ) const |
const_iterator & | operator-- () |
const_iterator | operator-- ( int ) |
const_iterator & | operator-= (int j ) |
const_iterator & | operator= (const const_iterator & other ) |
bool | operator== (const const_iterator & other ) const |
The QAssociativeIterable::const_iterator allows iteration over a container in a QVariant .
A QAssociativeIterable::const_iterator can only be created by a QAssociativeIterable instance, and can be used in a way similar to other stl-style iterators.
QHash<int, QString> mapping; mapping.insert(7, "Seven"); mapping.insert(11, "Eleven"); mapping.insert(42, "Forty-two"); QVariant variant = QVariant::fromValue(mapping); if (variant.canConvert<QVariantHash>()) { QAssociativeIterable iterable = variant.value<QAssociativeIterable>(); // Can use foreach over the values: foreach (const QVariant &v, iterable) { qDebug() << v; } // Can use C++11 range-for over the values: for (const QVariant &v : iterable) { qDebug() << v; } // Can use iterators: QAssociativeIterable::const_iterator it = iterable.begin(); const QAssociativeIterable::const_iterator end = iterable.end(); for ( ; it != end; ++it) { qDebug() << *it; // The current value qDebug() << it.key(); qDebug() << it.value(); } }
另请参阅 QAssociativeIterable .
创建副本为 other .
销毁 QAssociativeIterable::const_iterator .
Returns the current key, converted to a QVariant .
Returns the current value, converted to a QVariant .
返回
true
if
other
指向与此迭代器不同的项;否则返回
false
.
另请参阅 operator== ().
Returns the current value, converted to a QVariant .
Returns an iterator to the item at j positions forward from this iterator.
另请参阅 operator- () 和 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 QAssociativeIterable::end () leads to undefined results.
另请参阅 operator-- ().
这是重载函数。
The postfix ++ operator (
it++
) advances the iterator to the next item in the container and returns an iterator to the previously current item.
Advances the iterator by j 项。
另请参阅 operator-= () 和 operator+ ().
Returns an iterator to the item at j positions backward from this iterator.
另请参阅 operator+ () 和 operator-= ().
The prefix -- operator (
--it
) makes the preceding item current and returns an iterator to the new current item.
Calling this function on QAssociativeIterable::begin () leads to undefined results.
另请参阅 operator++ ().
这是重载函数。
The postfix -- operator (
it--
) makes the preceding item current and returns an iterator to the previously current item.
Makes the iterator go back by j 项。
另请参阅 operator+= () 和 operator- ().
赋值 other to this.
返回
true
if
other
points to the same item as this iterator; otherwise returns
false
.
另请参阅 operator!= ().