Detailed Description
The QJSValueIterator class provides a Java-style iterator for QJSValue.
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:
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:
Member Function Documentation
QJSValueIterator::QJSValueIterator(const QJSValue & object)
Constructs an iterator for traversing object. The iterator is set to be at the front of the sequence of properties (before the first property).
QJSValueIterator::~QJSValueIterator()
Destroys the iterator.
bool QJSValueIterator::hasNext() const
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 next().
QString QJSValueIterator::name() const
Returns the name of the last property that was jumped over using next().
See also value().
bool QJSValueIterator::next()
Advances the iterator by one position. 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.
Calling this function on an iterator located at the back of the container leads to undefined results.
See also hasNext() and name().
QJSValue QJSValueIterator::value() const
Returns the value of the last property that was jumped over using next().
See also name().
QJSValueIterator & QJSValueIterator::operator=(QJSValue & object)
Makes the iterator operate on object. The iterator is set to be at the front of the sequence of properties (before the first property).