QJSValueIterator Class

QJSValueIteratorクラスは、QJSValue のためのJavaスタイルのイテレータを提供します。さらに...

ヘッダー #include <QJSValueIterator>
CMake: find_package(Qt6 REQUIRED COMPONENTS Qml)
target_link_libraries(mytarget PRIVATE Qt6::Qml)
qmake: QT += qml

パブリック関数

QJSValueIterator(const QJSValue &object)
~QJSValueIterator()
bool hasNext() const
QString name() const
bool next()
QJSValue value() const
QJSValueIterator &operator=(QJSValue &object)

詳細説明

QJSValueIteratorコンストラクタは、引数としてQJSValue 。構築後、イテレータはプロパティのシーケンスの先頭に位置します。以下は、QJSValue のすべてのプロパティを反復処理する方法です:

QJSValueオブジェクト;...QJSValueIteratorit(object);while(it.hasNext()) { it.next();    qDebug() << it.name() << ": " << it.value().toString();
}

next() はイテレータを進める。name() とvalue() 関数は、最後にジャンプオーバーした項目の名前と値を返します。

QJSValueIteratorは、QJSValue'自身のプロパティを反復処理するだけであることに注意してください。プロトタイプ・チェインをたどるには、このようなループを使うことができます:

QJSValueobj= ...;// イテレートするオブジェクトwhile(obj.isObject()) {//it(obj); while (obj.isObject()) { // it(obj);//it(obj); while (obj.isObject())    QJSValueIteratorit(obj);while(it.hasNext()) { it.next();        qDebug() << it.name();
    } obj=obj.prototype(); }

QJSValue::property()も参照のこと

メンバ関数ドキュメント

QJSValueIterator::QJSValueIterator(const QJSValue &object)

object を走査するためのイテレータを構築します。イテレータは、プロパティのシーケンスの先頭 (最初のプロパティの前) に設定されます。

[noexcept] QJSValueIterator::~QJSValueIterator()

イテレータを破棄する。

bool QJSValueIterator::hasNext() const

イテレータの前に少なくとも1つのアイテムがある場合(つまり、イテレータがプロパティ・シーケンスの後ろにない場合)に真を返し、そうでない場合は偽を返します。

next()も参照してください

QString QJSValueIterator::name() const

next() を使用して最後にジャンプオーバーされたプロパティの名前を返します。

value()も参照

bool QJSValueIterator::next()

イテレータを 1 つ進めます。イテレータの前に少なくとも 1 つのアイテムがあった場合 (つまり、イテレータがすでにプロパティ・シーケンスの最後尾になかった場合) は true を返し、そうでない場合は false を返します。

hasNext() およびname()も参照

QJSValue QJSValueIterator::value() const

next() を使用して最後にジャンプオーバーされたプロパティの値を返します。

name()も参照

QJSValueIterator &QJSValueIterator::operator=(QJSValue &object)

イテレータをobject に対して動作させます。イテレータは、プロパティのシーケンスの先頭(最初のプロパティの前)に設定されます。

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