QMetaSequence::Iterable Class
class QMetaSequence::IterableQMetaSequence::Iterable クラスは、QVariant のコンテナのための反復可能なインターフェイスである。
このクラスは Qt 6.11 で導入されました。
パブリックタイプ
(since 6.11) class | ConstIterator |
(since 6.11) class | Iterator |
| BidirectionalConstIterator | |
| BidirectionalIterator | |
| ForwardConstIterator | |
| ForwardIterator | |
| InputConstIterator | |
| InputIterator | |
| RandomAccessConstIterator | |
| RandomAccessIterator |
パブリック関数
詳細説明
このクラスは、QVariant 内に保持されているコンテナの値にアクセスするためのいくつかのメソッドを提供します。QMetaSequence::Iterable のインスタンスは、QVariant からQVariantList に変換できる場合、またはQ_DECLARE_SEQUENTIAL_CONTAINER_METATYPE を使用してそのコンテナが登録されている場合に抽出できます。Qt に含まれるほとんどのシーケンシャル・コンテナと、C++ 標準ライブラリに含まれるいくつかのシーケンシャル・コンテナは、自動的に登録されます。
QList<int>intList= {7, 11, 42};QVariantvariant=QVariant::fromValue(intList);if(variant.canConvert<QVariantList>()) { QMetaSequence::Iterable iterable=variant.value<QMetaSequence::Iterable>();// C++11 の range-for が使える: for(constQVariant&v: iterable) { の場合 qDebug() << v; }// イテレータを使用できる: QMetaSequence::Iterable::const_iterator it=iterable.begin();constQMetaSequence::Iterable::const_iterator end=iterable.end();for( ; it!=end;++it) { . qDebug() << *it; } }
コンテナを反復処理する前に、コンテナ自体はコピーされない。
QVariantも参照のこと 。
メンバ型ドキュメント
[alias] Iterable::BidirectionalConstIterator
std::bidirectional_iterator_tag を使って const_iterator を公開しています。
[alias] Iterable::BidirectionalIterator
std::bidirectional_iterator_tag を使ってイテレータを公開します。
[alias] Iterable::ForwardConstIterator
std::forward_iterator_tag を使って const_iterator を公開しています。
[alias] Iterable::ForwardIterator
std::forward_iterator_tag を使ってイテレータを公開します。
[alias] Iterable::InputConstIterator
std::input_iterator_tag を使って const_iterator を公開します。
[alias] Iterable::InputIterator
std::input_iterator_tag を使ってイテレータを公開します。
[alias] Iterable::RandomAccessConstIterator
std::random_access_iterator_tag を使って const_iterator を公開します。
[alias] Iterable::RandomAccessIterator
std::random_access_iterator_tag を用いてイテレータを公開します。
メンバ関数ドキュメント
QVariant Iterable::at(qsizetype idx) const
コンテナ内の位置idx にある値を返します。
注意: 基礎となるコンテナがインデックスの要素を取得するネイティブな方法を提供していない場合、このメソッドはイテレータを使用してアクセスを合成します。この動作は非推奨であり、Qt の将来のバージョンでは削除される予定です。
setAt()も参照してください 。
void Iterable::setAt(qsizetype idx, const QVariant &value)
コンテナ内の位置idx にある要素をvalue に設定します。
at()も参照 。
© 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.