Table Of Contents

Previous topic

PySide.QtScript

Next topic

QScriptEngineAgent

QScriptValueIterator

Synopsis

Functions

Detailed Description

The PySide.QtScript.QScriptValueIterator class provides a Java-style iterator for PySide.QtScript.QScriptValue .

The PySide.QtScript.QScriptValueIterator constructor takes a PySide.QtScript.QScriptValue 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 PySide.QtScript.QScriptValue :

object = QScriptValue()
...
it = QScriptValueIterator(object)
while it.hasNext():
    it.next()
    print "%s:%s" % (it.name(), it.value().toString())

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

If you want to remove properties as you iterate over the PySide.QtScript.QScriptValue , use PySide.QtScript.QScriptValueIterator.remove() . If you want to modify the value of a property, use PySide.QtScript.QScriptValueIterator.setValue() .

Note that PySide.QtScript.QScriptValueIterator only iterates over the PySide.QtScript.QScriptValue ‘s own properties; i.e. it does not follow the prototype chain. You can use a loop like this to follow the prototype chain:

QScriptValue obj = ... // the object to iterate over
while obj.isObject():
    it = QScriptValueIterator(obj)
    while it.hasNext():
        it.next()
        print it.name()
    obj = obj.prototype()

Note that PySide.QtScript.QScriptValueIterator will not automatically skip over properties that have the QScriptValue.SkipInEnumeration flag set; that flag only affects iteration in script code. If you want, you can skip over such properties with code like the following:

while it.hasNext():
    it.next()
    if it.flags() & QScriptValue::SkipInEnumeration:
        continue
    print "found enumerated property: %s" % it.name()
class PySide.QtScript.QScriptValueIterator(value)
Parameters:valuePySide.QtScript.QScriptValue

Constructs an iterator for traversing object . The iterator is set to be at the front of the sequence of properties (before the first property).

PySide.QtScript.QScriptValueIterator.__iter__()
Return type:PyObject
PySide.QtScript.QScriptValueIterator.__next__()
Return type:PyObject
PySide.QtScript.QScriptValueIterator.flags()
Return type:PySide.QtScript.QScriptValue.PropertyFlags

Returns the flags of the last property that was jumped over using PySide.QtScript.QScriptValueIterator.next() or PySide.QtScript.QScriptValueIterator.previous() .

PySide.QtScript.QScriptValueIterator.hasNext()
Return type:PySide.QtCore.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.

PySide.QtScript.QScriptValueIterator.hasPrevious()
Return type:PySide.QtCore.bool

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

PySide.QtScript.QScriptValueIterator.name()
Return type:unicode

Returns the name of the last property that was jumped over using PySide.QtScript.QScriptValueIterator.next() or PySide.QtScript.QScriptValueIterator.previous() .

PySide.QtScript.QScriptValueIterator.next()

Advances the iterator by one position.

Calling this function on an iterator located at the back of the container leads to undefined results.

PySide.QtScript.QScriptValueIterator.previous()

Moves the iterator back by one position.

Calling this function on an iterator located at the front of the container leads to undefined results.

PySide.QtScript.QScriptValueIterator.remove()

Removes the last property that was jumped over using PySide.QtScript.QScriptValueIterator.next() or PySide.QtScript.QScriptValueIterator.previous() .

PySide.QtScript.QScriptValueIterator.scriptName()
Return type:PySide.QtScript.QScriptString

Returns the name of the last property that was jumped over using PySide.QtScript.QScriptValueIterator.next() or PySide.QtScript.QScriptValueIterator.previous() .

PySide.QtScript.QScriptValueIterator.setValue(value)
Parameters:valuePySide.QtScript.QScriptValue

Sets the value of the last property that was jumped over using PySide.QtScript.QScriptValueIterator.next() or PySide.QtScript.QScriptValueIterator.previous() .

PySide.QtScript.QScriptValueIterator.toBack()

Moves the iterator to the back of the PySide.QtScript.QScriptValue (after the last property).

PySide.QtScript.QScriptValueIterator.toFront()

Moves the iterator to the front of the PySide.QtScript.QScriptValue (before the first property).

PySide.QtScript.QScriptValueIterator.value()
Return type:PySide.QtScript.QScriptValue

Returns the value of the last property that was jumped over using PySide.QtScript.QScriptValueIterator.next() or PySide.QtScript.QScriptValueIterator.previous() .