- class QJSValueIterator#
The
QJSValueIterator
class provides a Java-style iterator forQJSValue
. More…Synopsis#
Methods#
def
__init__()
def
hasNext()
def
name()
def
next()
def
value()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description#
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
The
QJSValueIterator
constructor takes aQJSValue
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 aQJSValue
:object = QJSValue() ... it = QJSValueIterator(object) while it.hasNext(): it.next() print(it.name(), ": ", it.value().toString())
The
next()
advances the iterator. Thename()
andvalue()
functions return the name and value of the last item that was jumped over.Note that
QJSValueIterator
only iterates over theQJSValue
‘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
Constructs an iterator for traversing
object
. The iterator is set to be at the front of the sequence of properties (before the first property).- 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
- name()#
- Return type:
str
Returns the name of the last property that was jumped over using
next()
.See also
- 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.
Returns the value of the last property that was jumped over using
next()
.See also