このページでは

QMetaAssociation::Iterable::ConstIterator Class

class QMetaAssociation::Iterable::ConstIterator

QMetaAssociation::Iterable::ConstIterator は、QVariant のコンテナに対する反復を可能にする

このクラスは Qt 6.11 で導入されました。

パブリック関数

QVariant key() const
QVariant value() const
QVariant operator*() const
int operator->() const

詳細説明

QMetaAssociation::Iterable::ConstIterator は、QMetaAssociation::Iterable インスタンスによってのみ作成することができ、他の stl スタイルのイテレータと同様の方法で使用することができます。

QHash<intQString> mapping; mapping.insert(7, "Seven"); mapping.insert(11, "Eleven"); mapping.insert(42, "Forty-two");QVariantvariant=QVariant::fromValue(mapping);if(variant.canConvert<QVariantHash>()) { QMetaAssociation::Iterable iterable=variant.value<QMetaAssociationif (variant canConvert< >()) { ::Iterable iterable = variant.value<::Iterable>();// C++11 range-for over the values: for(constQVariant&v: iterable) { の場合        qDebug() << v;
    }// イテレータを使用できるQMetaAssociation::Iterable::const_iterator it=iterable.begin();constQMetaAssociation::Iterable::const_iterator end=iterable.end();for( ; it!=end;++it) { .        qDebug() << *it; // The current value
        qDebug() << it.key();
        qDebug() << it.value();
    } }

QMetaAssociation::Iterableも参照のこと

メンバ関数のドキュメント

QVariant ConstIterator::key() const

このイテレータが指すキーを返します。

QVariant ConstIterator::value() const

このイテレータが指すマップされた値、またはマップされた値がない場合は無効なQVariant を返します。

QVariant ConstIterator::operator*() const

現在のアイテムをQVariant に変換して返します。 返される値は、現在のイテレータがあればそのイテレータにマップされた値、なければキーです。

int ConstIterator::operator->() const

現在のアイテムをQVariant::ConstPointer に変換して返します。QVariant::ConstPointer は、現在のイテレータにマップされた値がある場合はその値に解決し、ない場合はキーに解決します。

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