内容表

上一话题

QJSValue

下一话题

QQmlAbstractUrlInterceptor

QJSValueIterator

QJSValueIterator class provides a Java-style iterator for QJSValue . 更多

Inheritance diagram of PySide2.QtQml.QJSValueIterator

概要

函数

详细描述

QJSValueIterator constructor takes a QJSValue as argument. After construction, the iterator is located at the very beginning of the sequence of properties. Here’s how to iterate over all the properties of a QJSValue :

QJSValue object;
...
QJSValueIterator it(object);
while (it.hasNext()) {
    it.next();
    qDebug() << it.name() << ": " << it.value().toString();
}
											

next() advances the iterator. The name() and value() functions return the name and value of the last item that was jumped over.

注意: QJSValueIterator only iterates over the QJSValue ‘s own properties; i.e. it does not follow the prototype chain. You can use a loop like this to follow the prototype chain:

QJSValue obj = ...; // the object to iterate over
while (obj.isObject()) {
    QJSValueIterator it(obj);
    while (it.hasNext()) {
        it.next();
        qDebug() << it.name();
    }
    obj = obj.prototype();
}
											

另请参阅

property()

class QJSValueIterator ( value )
参数

value QJSValue

PySide2.QtQml.QJSValueIterator. hasNext ( )
返回类型

bool

Returns true if there is at least one item ahead of the iterator (i.e. the iterator is not at the back of the property sequence); otherwise returns false.

另请参阅

next()

PySide2.QtQml.QJSValueIterator. name ( )
返回类型

unicode

Returns the name of the last property that was jumped over using next() .

另请参阅

value()

PySide2.QtQml.QJSValueIterator. next ( )
返回类型

bool

Advances the iterator by one position. Returns true if there was at least one item ahead of the iterator (i.e. the iterator was not already at the back of the property sequence); otherwise returns false.

PySide2.QtQml.QJSValueIterator.operator=(value)
参数

value QJSValue

返回类型

QJSValueIterator

PySide2.QtQml.QJSValueIterator. value ( )
返回类型

QJSValue

Returns the value of the last property that was jumped over using next() .

另请参阅

name()