QJSValueIterator¶
The QJSValueIterator
class provides a Java-style iterator for QJSValue
. More…
Synopsis¶
Functions¶
Detailed Description¶
The 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
:
object = QJSValue() ... it = QJSValueIterator(object) while it.hasNext(): it.next() print(it.name(), ": ", it.value().toString())
The next()
advances the iterator. The name()
and value()
functions return the name and value of the last item that was jumped over.
Note that 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:
obj = ... # the object to iterate over while obj.isObject(): it = QJSValueIterator(obj) while (it.hasNext()) { it.next() print(it.name()) obj = obj.prototype()See also
- class PySide6.QtQml.QJSValueIterator(value)¶
- Parameters
value –
PySide6.QtQml.QJSValue
Constructs an iterator for traversing object
. The iterator is set to be at the front of the sequence of properties (before the first property).
- PySide6.QtQml.QJSValueIterator.hasNext()¶
- Return type
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.
See also
- PySide6.QtQml.QJSValueIterator.name()¶
- Return type
str
Returns the name of the last property that was jumped over using next()
.
See also
- PySide6.QtQml.QJSValueIterator.next()¶
- Return type
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.
- PySide6.QtQml.QJSValueIterator.value()¶
- Return type
Returns the value of the last property that was jumped over using next()
.
See also
© 2022 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.