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

    上一话题

    QScriptClass

    下一话题

    QScriptable

    QScriptValue

    概要

    函数

    详细描述

    PySide.QtScript.QScriptValue class acts as a container for the Qt Script data types.

    PySide.QtScript.QScriptValue supports the types defined in the ECMA-262 standard: The primitive types, which are Undefined, Null, Boolean, Number, and String; and the Object type. Additionally, Qt Script has built-in support for PySide.QtCore.QVariant , PySide.QtCore.QObject and PySide.QtCore.QMetaObject .

    For the object-based types (including Date and RegExp), use the newT() functions in PySide.QtScript.QScriptEngine (e.g. QScriptEngine.newObject() ) to create a PySide.QtScript.QScriptValue of the desired type. For the primitive types, use one of the PySide.QtScript.QScriptValue constructor overloads.

    The methods named isT() (e.g. PySide.QtScript.QScriptValue.isBool() , PySide.QtScript.QScriptValue.isUndefined() ) can be used to test if a value is of a certain type. The methods named toT() (e.g. PySide.QtScript.QScriptValue.toBool() , PySide.QtScript.QScriptValue.toString() ) can be used to convert a PySide.QtScript.QScriptValue to another type. You can also use the generic qscriptvalue_cast() 函数。

    Object values have zero or more properties which are themselves QScriptValues. Use PySide.QtScript.QScriptValue.setProperty() to set a property of an object, and call PySide.QtScript.QScriptValue.property() to retrieve the value of a property.

    myEngine = QScriptEngine()
    myObject = myEngine.newObject()
    myOtherObject = myEngine.newObject()
    myObject.setProperty("myChild", myOtherObject)
    myObject.setProperty("name", "John Doe")
    										

    Each property can have a set of attributes; these are specified as the third (optional) argument to PySide.QtScript.QScriptValue.setProperty() . The attributes of a property can be queried by calling the PySide.QtScript.QScriptValue.propertyFlags() function. The following code snippet creates a property that cannot be modified by script code:

    val = QScriptValue(myEngine, 123)
    myObject.setProperty("myReadOnlyProperty", val, QScriptValue.ReadOnly)
    										

    If you want to iterate over the properties of a script object, use the PySide.QtScript.QScriptValueIterator 类。

    Object values have an internal prototype property, which can be accessed with PySide.QtScript.QScriptValue.prototype() and PySide.QtScript.QScriptValue.setPrototype() . Properties added to a prototype are shared by all objects having that prototype; this is referred to as prototype-based inheritance. In practice, it means that (by default) the PySide.QtScript.QScriptValue.property() function will automatically attempt to look up look the property in the PySide.QtScript.QScriptValue.prototype() (and in the prototype of the PySide.QtScript.QScriptValue.prototype() , and so on), if the object itself does not have the requested property. Note that this prototype-based lookup is not performed by PySide.QtScript.QScriptValue.setProperty() ; PySide.QtScript.QScriptValue.setProperty() will always create the property in the script object itself. 更多信息,见 QtScript 文档编制。

    Function objects (objects for which PySide.QtScript.QScriptValue.isFunction() returns true) can be invoked by calling PySide.QtScript.QScriptValue.call() . Constructor functions can be used to construct new objects by calling PySide.QtScript.QScriptValue.construct() .

    使用 PySide.QtScript.QScriptValue.equals() , PySide.QtScript.QScriptValue.strictlyEquals() and PySide.QtScript.QScriptValue.lessThan() to compare a PySide.QtScript.QScriptValue to another.

    Object values can have custom data associated with them; see the PySide.QtScript.QScriptValue.setData() and PySide.QtScript.QScriptValue.data() functions. By default, this data is not accessible to scripts; it can be used to store any data you want to associate with the script object. Typically this is used by custom class objects (see PySide.QtScript.QScriptClass ) to store a C++ type that contains the “native” object data.

    注意: PySide.QtScript.QScriptValue for which PySide.QtScript.QScriptValue.isObject() is true only carries a reference to an actual object; copying the PySide.QtScript.QScriptValue will only copy the object reference, not the object itself. If you want to clone an object (i.e. copy an object's properties to another object), you can do so with the help of a for-in statement in script code, or PySide.QtScript.QScriptValueIterator in C++.

    class PySide.QtScript. QScriptValue
    class PySide.QtScript. QScriptValue ( engine , val )
    class PySide.QtScript. QScriptValue ( engine , val )
    class PySide.QtScript. QScriptValue ( engine , val )
    class PySide.QtScript. QScriptValue ( engine , val )
    class PySide.QtScript. QScriptValue ( engine , val )
    class PySide.QtScript. QScriptValue ( engine , val )
    class PySide.QtScript. QScriptValue ( engine , val )
    class PySide.QtScript. QScriptValue ( value )
    class PySide.QtScript. QScriptValue ( value )
    class PySide.QtScript. QScriptValue ( other )
    class PySide.QtScript. QScriptValue ( value )
    class PySide.QtScript. QScriptValue ( value )
    class PySide.QtScript. QScriptValue ( value )
    class PySide.QtScript. QScriptValue ( value )
    class PySide.QtScript. QScriptValue ( value )
    参数:

    Constructs an invalid PySide.QtScript.QScriptValue .

    构造新 PySide.QtScript.QScriptValue with the special value and registers it with the script engine .

    构造新 PySide.QtScript.QScriptValue with the boolean value and registers it with the script engine .

    构造新 PySide.QtScript.QScriptValue with the string value and registers it with the script engine .

    构造新 PySide.QtScript.QScriptValue with the string value and registers it with the script engine .

    构造新 PySide.QtScript.QScriptValue with the integer value and registers it with the script engine .

    构造新 PySide.QtScript.QScriptValue with the unsigned integer value and registers it with the script engine .

    构造新 PySide.QtScript.QScriptValue with a special value .

    构造新 PySide.QtScript.QScriptValue with a boolean value .

    构造新 PySide.QtScript.QScriptValue that is a copy of other .

    注意:若 other is an object (i.e., PySide.QtScript.QScriptValue.isObject() would return true), then only a reference to the underlying object is copied into the new script value (i.e., the object itself is not copied).

    构造新 PySide.QtScript.QScriptValue with a string value .

    构造新 PySide.QtScript.QScriptValue with a string value .

    构造新 PySide.QtScript.QScriptValue with a number value .

    构造新 PySide.QtScript.QScriptValue with a number value .

    PySide.QtScript.QScriptValue. ResolveFlag

    This enum specifies how to look up a property of an object.

    常量 描述
    QScriptValue.ResolveLocal Only check the object's own properties.
    QScriptValue.ResolvePrototype Check the object's own properties first, then search the prototype chain. This is the default.

    Check the object's own properties first, then search the scope chain.

    Check the object's own properties first, then search the prototype chain, and finally search the scope chain.

    PySide.QtScript.QScriptValue. PropertyFlag

    This enum describes the attributes of a property.

    常量 描述
    QScriptValue.ReadOnly The property is read-only. Attempts by Qt Script code to write to the property will be ignored.
    QScriptValue.Undeletable Attempts by Qt Script code to delete the property will be ignored.
    QScriptValue.SkipInEnumeration The property is not to be enumerated by a for-in enumeration.
    QScriptValue.PropertyGetter The property is defined by a function which will be called to get the property value.
    QScriptValue.PropertySetter The property is defined by a function which will be called to set the property value.

    This flag is used to indicate that an existing property is a PySide.QtCore.QObject member (a property or method).

    常量 描述
    QScriptValue.KeepExistingFlags This value is used to indicate to PySide.QtScript.QScriptValue.setProperty() that the property's flags should be left unchanged. If the property doesn't exist, the default flags (0) will be used.

    Flags in this range are not used by Qt Script, and can be used for custom purposes.

    PySide.QtScript.QScriptValue. SpecialValue

    This enum is used to specify a single-valued type.

    常量 描述
    QScriptValue.UndefinedValue An undefined value.
    QScriptValue.NullValue A null value.
    PySide.QtScript.QScriptValue. __iter__ ( )
    返回类型: PyObject
    PySide.QtScript.QScriptValue. __mgetitem__ ( )
    PySide.QtScript.QScriptValue. __repr__ ( )
    返回类型: PyObject
    PySide.QtScript.QScriptValue. call ( thisObject , arguments )
    参数:
    返回类型:

    PySide.QtScript.QScriptValue

    Calls this PySide.QtScript.QScriptValue as a function, using thisObject 作为 this' object in the function call, and passing ``arguments` as arguments to the function. Returns the value returned from the function.

    若此 PySide.QtScript.QScriptValue is not a function, PySide.QtScript.QScriptValue.call() does nothing and returns an invalid PySide.QtScript.QScriptValue .

    arguments can be an arguments object, an array, null or undefined; any other type will cause a TypeError to be thrown.

    注意:若 thisObject is not an object, the global object (see QScriptEngine.globalObject() ) will be used as the ` this' object.

    One common usage of this function is to forward native function calls to another function:

    def myNativeFunction(context, engine):
        otherFunction = ...
        return otherFunction.call(context.thisObject(), context.argumentsObject())
    											
    PySide.QtScript.QScriptValue. call ( [ thisObject=QScriptValue() [ , args=QScriptValueList() ] ] )
    参数:
    返回类型:

    PySide.QtScript.QScriptValue

    PySide.QtScript.QScriptValue. construct ( [ args=QScriptValueList() ] )
    参数: args
    返回类型: PySide.QtScript.QScriptValue
    PySide.QtScript.QScriptValue. construct ( arguments )
    参数: arguments PySide.QtScript.QScriptValue
    返回类型: PySide.QtScript.QScriptValue

    创建新的 对象 and calls this PySide.QtScript.QScriptValue as a constructor, using the created object as the this' object and passing ``arguments` as arguments. If the return value from the constructor call is an object, then that object is returned; otherwise the default constructed object is returned.

    若此 PySide.QtScript.QScriptValue is not a function, PySide.QtScript.QScriptValue.construct() does nothing and returns an invalid PySide.QtScript.QScriptValue .

    arguments can be an arguments object, an array, null or undefined. Any other type will cause a TypeError to be thrown.

    PySide.QtScript.QScriptValue. data ( )
    返回类型: PySide.QtScript.QScriptValue

    Returns the internal data of this PySide.QtScript.QScriptValue 对象。 QtScript uses this property to store the primitive value of Date, String, Number and Boolean objects. For other types of object, custom data may be stored using PySide.QtScript.QScriptValue.setData() .

    PySide.QtScript.QScriptValue. engine ( )
    返回类型: PySide.QtScript.QScriptEngine

    返回 PySide.QtScript.QScriptEngine that created this PySide.QtScript.QScriptValue , or 0 if this PySide.QtScript.QScriptValue is invalid or the value is not associated with a particular engine.

    PySide.QtScript.QScriptValue. equals ( other )
    参数: other PySide.QtScript.QScriptValue
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue is equal to other , otherwise returns false. The comparison follows the behavior described in ECMA-262 section 11.9.3, “The Abstract Equality Comparison Algorithm”.

    This function can return true even if the type of this PySide.QtScript.QScriptValue is different from the type of the other value; i.e. the comparison is not strict. For example, comparing the number 9 to the string “9” returns true; comparing an undefined value to a null value returns true; comparing a Number object whose primitive value is 6 to a 字符串 object whose primitive value is “6” returns true; and comparing the number 1 to the boolean value true returns true. If you want to perform a comparison without such implicit value conversion, use PySide.QtScript.QScriptValue.strictlyEquals() .

    Note that if this PySide.QtScript.QScriptValue other value are objects, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly PySide.QtScript.QScriptValue.toString() ) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).

    PySide.QtScript.QScriptValue. instanceOf ( other )
    参数: other PySide.QtScript.QScriptValue
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue is an instance of other ;否则返回 false。

    This PySide.QtScript.QScriptValue is considered to be an instance of other if other is a function and the value of the prototype property of other is in the prototype chain of this PySide.QtScript.QScriptValue .

    PySide.QtScript.QScriptValue. isArray ( )
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue is an object of the Array class; otherwise returns false.

    PySide.QtScript.QScriptValue. isBool ( )
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue is of the primitive type Boolean; otherwise returns false.

    PySide.QtScript.QScriptValue. isBoolean ( )
    返回类型: PySide.QtCore.bool

    使用 PySide.QtScript.QScriptValue.isBool() 代替。

    PySide.QtScript.QScriptValue. isDate ( )
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue is an object of the Date class; otherwise returns false.

    PySide.QtScript.QScriptValue. isError ( )
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue is an object of the Error class; otherwise returns false.

    PySide.QtScript.QScriptValue. isFunction ( )
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue is a function; otherwise returns false.

    PySide.QtScript.QScriptValue. isNull ( )
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue is of the primitive type Null; otherwise returns false.

    PySide.QtScript.QScriptValue. isNumber ( )
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue is of the primitive type Number; otherwise returns false.

    PySide.QtScript.QScriptValue. isObject ( )
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue is of the Object type; otherwise returns false.

    Note that function values, variant values, and PySide.QtCore.QObject values are objects, so this function returns true for such values.

    PySide.QtScript.QScriptValue. isQMetaObject ( )
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue PySide.QtCore.QMetaObject ;否则返回 false。

    PySide.QtScript.QScriptValue. isQObject ( )
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue PySide.QtCore.QObject ;否则返回 false。

    Note: This function returns true even if the PySide.QtCore.QObject that this PySide.QtScript.QScriptValue wraps has been deleted.

    PySide.QtScript.QScriptValue. isRegExp ( )
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue is an object of the RegExp class; otherwise returns false.

    PySide.QtScript.QScriptValue. isString ( )
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue is of the primitive type String; otherwise returns false.

    PySide.QtScript.QScriptValue. isUndefined ( )
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue is of the primitive type Undefined; otherwise returns false.

    PySide.QtScript.QScriptValue. isValid ( )
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue is valid; otherwise returns false.

    PySide.QtScript.QScriptValue. isVariant ( )
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue is a variant value; otherwise returns false.

    PySide.QtScript.QScriptValue. lessThan ( other )
    参数: other PySide.QtScript.QScriptValue
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue is less than other , otherwise returns false. The comparison follows the behavior described in ECMA-262 section 11.8.5, “The Abstract Relational Comparison Algorithm”.

    Note that if this PySide.QtScript.QScriptValue other value are objects, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly PySide.QtScript.QScriptValue.toString() ) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).

    PySide.QtScript.QScriptValue. objectId ( )
    返回类型: PySide.QtCore.qint64

    Returns the ID of this object, or -1 if this PySide.QtScript.QScriptValue is not an object.

    PySide.QtScript.QScriptValue. property ( arrayIndex [ , mode=QScriptValue.ResolvePrototype ] )
    参数:
    • arrayIndex PySide.QtCore.quint32
    • mode PySide.QtScript.QScriptValue.ResolveFlags
    返回类型:

    PySide.QtScript.QScriptValue

    这是重载函数。

    Returns the property at the given arrayIndex ,使用给定 mode to resolve the property.

    This function is provided for convenience and performance when working with array objects.

    若此 PySide.QtScript.QScriptValue is not an Array object, this function behaves as if PySide.QtScript.QScriptValue.property() was called with the string representation of arrayIndex .

    PySide.QtScript.QScriptValue. property ( name [ , mode=QScriptValue.ResolvePrototype ] )
    参数:
    • name – unicode
    • mode PySide.QtScript.QScriptValue.ResolveFlags
    返回类型:

    PySide.QtScript.QScriptValue

    Returns the value of this PySide.QtScript.QScriptValue ‘s property with the given name ,使用给定 mode to resolve the property.

    If no such property exists, an invalid PySide.QtScript.QScriptValue 被返回。

    If the property is implemented using a getter function (i.e. has the PropertyGetter flag set), calling PySide.QtScript.QScriptValue.property() has side-effects on the script engine, since the getter function will be called (possibly resulting in an uncaught script exception). If an exception occurred, PySide.QtScript.QScriptValue.property() returns the value that was thrown (typically an Error 对象)。

    PySide.QtScript.QScriptValue. property ( name [ , mode=QScriptValue.ResolvePrototype ] )
    参数:
    返回类型:

    PySide.QtScript.QScriptValue

    Returns the value of this PySide.QtScript.QScriptValue ‘s property with the given name ,使用给定 mode to resolve the property.

    This overload of PySide.QtScript.QScriptValue.property() is useful when you need to look up the same property repeatedly, since the lookup can be performed faster when the name is represented as an interned string.

    PySide.QtScript.QScriptValue. propertyFlags ( name [ , mode=QScriptValue.ResolvePrototype ] )
    参数:
    • name – unicode
    • mode PySide.QtScript.QScriptValue.ResolveFlags
    返回类型:

    PySide.QtScript.QScriptValue.PropertyFlags

    Returns the flags of the property with the given name ,使用给定 mode to resolve the property.

    PySide.QtScript.QScriptValue. propertyFlags ( name [ , mode=QScriptValue.ResolvePrototype ] )
    参数:
    返回类型:

    PySide.QtScript.QScriptValue.PropertyFlags

    Returns the flags of the property with the given name ,使用给定 mode to resolve the property.

    PySide.QtScript.QScriptValue. prototype ( )
    返回类型: PySide.QtScript.QScriptValue

    若此 PySide.QtScript.QScriptValue is an object, returns the internal prototype ( __proto__ property) of this object; otherwise returns an invalid PySide.QtScript.QScriptValue .

    PySide.QtScript.QScriptValue. scope ( )
    返回类型: PySide.QtScript.QScriptValue
    PySide.QtScript.QScriptValue. scriptClass ( )
    返回类型: PySide.QtScript.QScriptClass

    Returns the custom script class that this script object is an instance of, or 0 if the object is not of a custom class.

    PySide.QtScript.QScriptValue. setData ( data )
    参数: data PySide.QtScript.QScriptValue

    Sets the internal data of this PySide.QtScript.QScriptValue object. You can use this function to set object-specific data that won't be directly accessible to scripts, but may be retrieved in C++ using the PySide.QtScript.QScriptValue.data() 函数。

    PySide.QtScript.QScriptValue. setProperty ( name , value [ , flags=QScriptValue.KeepExistingFlags ] )
    参数:

    Sets the value of this PySide.QtScript.QScriptValue ‘s property with the given name 到给定 value .

    若此 PySide.QtScript.QScriptValue is not an object, this function does nothing.

    若此 PySide.QtScript.QScriptValue does not already have a property with name name , a new property is created; the given flags then specify how this property may be accessed by script code.

    value is invalid, the property is removed.

    If the property is implemented using a setter function (i.e. has the PropertySetter flag set), calling PySide.QtScript.QScriptValue.setProperty() has side-effects on the script engine, since the setter function will be called with the given value as argument (possibly resulting in an uncaught script exception).

    Note that you cannot specify custom getter or setter functions for built-in properties, such as the length property of Array objects or meta properties of PySide.QtCore.QObject 对象。

    PySide.QtScript.QScriptValue. setProperty ( arrayIndex , value [ , flags=QScriptValue.KeepExistingFlags ] )
    参数:

    这是重载函数。

    Sets the property at the given arrayIndex 到给定 value .

    This function is provided for convenience and performance when working with array objects.

    若此 PySide.QtScript.QScriptValue is not an Array object, this function behaves as if PySide.QtScript.QScriptValue.setProperty() was called with the string representation of arrayIndex .

    PySide.QtScript.QScriptValue. setProperty ( name , value [ , flags=QScriptValue.KeepExistingFlags ] )
    参数:

    Sets the value of this PySide.QtScript.QScriptValue ‘s property with the given name 到给定 value . The given flags specify how this property may be accessed by script code.

    This overload of PySide.QtScript.QScriptValue.setProperty() is useful when you need to set the same property repeatedly, since the operation can be performed faster when the name is represented as an interned string.

    PySide.QtScript.QScriptValue. setPrototype ( prototype )
    参数: prototype PySide.QtScript.QScriptValue

    若此 PySide.QtScript.QScriptValue is an object, sets the internal prototype ( __proto__ property) of this object to be prototype ; otherwise does nothing.

    The internal prototype should not be confused with the public property with name “prototype”; the public prototype is usually only set on functions that act as constructors.

    PySide.QtScript.QScriptValue. setScope ( scope )
    参数: scope PySide.QtScript.QScriptValue
    PySide.QtScript.QScriptValue. setScriptClass ( scriptClass )
    参数: scriptClass PySide.QtScript.QScriptClass

    Sets the custom script class of this script object to scriptClass . This can be used to “promote” a plain script object (e.g. created by the “new” operator in a script, or by QScriptEngine.newObject() in C++) to an object of a custom type.

    scriptClass is 0, the object will be demoted to a plain script object.

    PySide.QtScript.QScriptValue. strictlyEquals ( other )
    参数: other PySide.QtScript.QScriptValue
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtScript.QScriptValue is equal to other using strict comparison (no conversion), otherwise returns false. The comparison follows the behavior described in ECMA-262 section 11.9.6, “The Strict Equality Comparison Algorithm”.

    If the type of this PySide.QtScript.QScriptValue is different from the type of the other value, this function returns false. If the types are equal, the result depends on the type, as shown in the following table:

    Type 结果
    Undefined true
    Null true
    布尔 true if both values are true, false otherwise
    Number false if either value is NaN (Not-a-Number); true if values are equal, false otherwise
    字符串 true if both values are exactly the same sequence of characters, false otherwise
    对象 true if both values refer to the same object, false otherwise
    PySide.QtScript.QScriptValue. toBool ( )
    返回类型: PySide.QtCore.bool

    Returns the boolean value of this PySide.QtScript.QScriptValue , using the conversion rules described in ECMA-262 section 9.2, “ToBoolean”.

    Note that if this PySide.QtScript.QScriptValue is an object, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly PySide.QtScript.QScriptValue.toString() ) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).

    PySide.QtScript.QScriptValue. toBoolean ( )
    返回类型: PySide.QtCore.bool

    使用 PySide.QtScript.QScriptValue.toBool() 代替。

    PySide.QtScript.QScriptValue. toDateTime ( )
    返回类型: PySide.QtCore.QDateTime

    返回 PySide.QtCore.QDateTime representation of this value, in local time. If this PySide.QtScript.QScriptValue is not a date, or the value of the date is NaN (Not-a-Number), an invalid PySide.QtCore.QDateTime 被返回。

    PySide.QtScript.QScriptValue. toInt32 ( )
    返回类型: PySide.QtCore.qint32

    Returns the signed 32-bit integer value of this PySide.QtScript.QScriptValue , using the conversion rules described in ECMA-262 section 9.5, “ToInt32”.

    Note that if this PySide.QtScript.QScriptValue is an object, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly PySide.QtScript.QScriptValue.toString() ) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).

    PySide.QtScript.QScriptValue. toInteger ( )
    返回类型: PySide.QtCore.double

    Returns the integer value of this PySide.QtScript.QScriptValue , using the conversion rules described in ECMA-262 section 9.4, “ToInteger”.

    Note that if this PySide.QtScript.QScriptValue is an object, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly PySide.QtScript.QScriptValue.toString() ) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).

    PySide.QtScript.QScriptValue. toNumber ( )
    返回类型: PySide.QtCore.double

    Returns the number value of this PySide.QtScript.QScriptValue , as defined in ECMA-262 section 9.3, “ToNumber”.

    Note that if this PySide.QtScript.QScriptValue is an object, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly PySide.QtScript.QScriptValue.toString() ) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).

    PySide.QtScript.QScriptValue. toObject ( )
    返回类型: PySide.QtScript.QScriptValue

    This function is obsolete; use QScriptEngine.toObject() 代替。

    PySide.QtScript.QScriptValue. toQMetaObject ( )
    返回类型: PySide.QtCore.QMetaObject

    若此 PySide.QtScript.QScriptValue PySide.QtCore.QMetaObject , returns the PySide.QtCore.QMetaObject pointer that the PySide.QtScript.QScriptValue represents; otherwise, returns 0.

    PySide.QtScript.QScriptValue. toQObject ( )
    返回类型: PySide.QtCore.QObject

    若此 PySide.QtScript.QScriptValue PySide.QtCore.QObject , returns the PySide.QtCore.QObject pointer that the PySide.QtScript.QScriptValue represents; otherwise, returns 0.

    PySide.QtCore.QObject that this PySide.QtScript.QScriptValue wraps has been deleted, this function returns 0 (i.e. it is possible for PySide.QtScript.QScriptValue.toQObject() to return 0 even when PySide.QtScript.QScriptValue.isQObject() returns true).

    PySide.QtScript.QScriptValue. toRegExp ( )
    返回类型: PySide.QtCore.QRegExp

    返回 PySide.QtCore.QRegExp representation of this value. If this PySide.QtScript.QScriptValue is not a regular expression, an empty PySide.QtCore.QRegExp 被返回。

    PySide.QtScript.QScriptValue. toString ( )
    返回类型: unicode

    Returns the string value of this PySide.QtScript.QScriptValue , as defined in ECMA-262 section 9.8, “ToString”.

    Note that if this PySide.QtScript.QScriptValue is an object, calling this function has side effects on the script engine, since the engine will call the object's PySide.QtScript.QScriptValue.toString() function (and possibly valueOf()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).

    PySide.QtScript.QScriptValue. toUInt16 ( )
    返回类型: PySide.QtCore.quint16

    Returns the unsigned 16-bit integer value of this PySide.QtScript.QScriptValue , using the conversion rules described in ECMA-262 section 9.7, “ToUint16”.

    Note that if this PySide.QtScript.QScriptValue is an object, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly PySide.QtScript.QScriptValue.toString() ) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).

    PySide.QtScript.QScriptValue. toUInt32 ( )
    返回类型: PySide.QtCore.quint32

    Returns the unsigned 32-bit integer value of this PySide.QtScript.QScriptValue , using the conversion rules described in ECMA-262 section 9.6, “ToUint32”.

    Note that if this PySide.QtScript.QScriptValue is an object, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly PySide.QtScript.QScriptValue.toString() ) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).

    PySide.QtScript.QScriptValue. toVariant ( )
    返回类型: object

    返回 PySide.QtCore.QVariant value of this PySide.QtScript.QScriptValue , if it can be converted to a PySide.QtCore.QVariant ; otherwise returns an invalid PySide.QtCore.QVariant . The conversion is performed according to the following table:

    Input Type 结果
    Undefined An invalid PySide.QtCore.QVariant .
    Null An invalid PySide.QtCore.QVariant .
    布尔 A PySide.QtCore.QVariant containing the value of the boolean.
    Number A PySide.QtCore.QVariant containing the value of the number.
    字符串 A PySide.QtCore.QVariant containing the value of the string.
    PySide.QtCore.QVariant 对象 The result is the PySide.QtCore.QVariant value of the object (no conversion).
    PySide.QtCore.QObject 对象 A PySide.QtCore.QVariant containing a pointer to the PySide.QtCore.QObject .
    Date Object A PySide.QtCore.QVariant containing the date value ( PySide.QtScript.QScriptValue.toDateTime() ).
    RegExp Object A PySide.QtCore.QVariant containing the regular expression value ( PySide.QtScript.QScriptValue.toRegExp() ).
    Array Object The array is converted to a QVariantList . Each element is converted to a PySide.QtCore.QVariant , recursively; cyclic references are not followed.
    对象 The object is converted to a PySide.QtCore.QVariantMap . Each property is converted to a PySide.QtCore.QVariant , recursively; cyclic references are not followed.