• PySide 模块
  • PySide.QtScript
  • 内容表表

    上一话题

    PySide.QtScript

    下一话题

    QScriptEngineAgent

    QScriptValueIterator

    概要

    函数

    详细描述

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

    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())
    										

    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 ,使用 PySide.QtScript.QScriptValueIterator.remove() . If you want to modify the value of a property, use PySide.QtScript.QScriptValueIterator.setValue() .

    注意: 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()
    									

    注意: 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 )
    参数: value PySide.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__ ( )
    返回类型: PyObject
    PySide.QtScript.QScriptValueIterator. __next__ ( )
    返回类型: PyObject
    PySide.QtScript.QScriptValueIterator. flags ( )
    返回类型: 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 ( )
    返回类型: 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 ( )
    返回类型: 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 ( )
    返回类型: 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. 上一 ( )

    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 ( )
    返回类型: 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 )
    参数: value PySide.QtScript.QScriptValue

    设置 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 ( )
    返回类型: PySide.QtScript.QScriptValue

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