Qyoto  4.0.5
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtScript.QScriptValue Class Reference

The QScriptValue class acts as a container for the Qt Script data types. More...

Inheritance diagram for QtScript.QScriptValue:
Collaboration diagram for QtScript.QScriptValue:

Public Types

enum  PropertyFlag {
  KeepExistingFlags = 2048, PropertyGetter = 8, PropertySetter = 16, QObjectMember = 32,
  ReadOnly = 1, SkipInEnumeration = 4, Undeletable = 2, UserRange = -16777216
}
  More...
 
enum  ResolveFlag { ResolveFull = 3, ResolveLocal = 0, ResolvePrototype = 1, ResolveScope = 2 }
  More...
 
enum  SpecialValue { NullValue = 0, UndefinedValue = 1 }
  More...
 

Public Member Functions

 QScriptValue ()
 
 
 QScriptValue (QScriptValue other)
 
 
 QScriptValue (QLatin1String value)
 
 
 QScriptValue (QScriptEngine engine, QScriptValue.SpecialValue val)
 
 
 QScriptValue (QScriptEngine engine, bool val)
 
 
 QScriptValue (QScriptEngine engine, int val)
 
 
 QScriptValue (QScriptEngine engine, uint val)
 
 
 QScriptValue (QScriptEngine engine, double val)
 
 
 QScriptValue (QScriptEngine engine, string val)
 
 
 QScriptValue (QScriptValue.SpecialValue value)
 
 
 QScriptValue (bool value)
 
 
 QScriptValue (int value)
 
 
 QScriptValue (uint value)
 
 
 QScriptValue (double value)
 
 
 QScriptValue (string value)
 
 
virtual void CreateProxy ()
 
new QScriptValue Call ()
 
 
new QScriptValue Call (QScriptValue thisObject)
 
 
new QScriptValue Call (QScriptValue thisObject, QScriptValue arguments)
 
 
new QScriptValue Call (QScriptValue thisObject, System.Collections.Generic.List< QScriptValue > args)
 
 
new QScriptValue Construct ()
 
 
new QScriptValue Construct (QScriptValue arguments)
 
 
new QScriptValue Construct (System.Collections.Generic.List< QScriptValue > args)
 
 
new QScriptEngine Engine ()
 
 
new bool Equals (QScriptValue other)
 
 
new bool InstanceOf (QScriptValue other)
 
 
new bool IsArray ()
 
 
new bool IsBool ()
 
 
new bool IsBoolean ()
 
 
new bool IsDate ()
 
 
new bool IsError ()
 
 
new bool IsFunction ()
 
 
new bool IsNull ()
 
 
new bool IsNumber ()
 
 
new bool IsObject ()
 
 
new bool IsQMetaObject ()
 
 
new bool IsQObject ()
 
 
new bool IsRegExp ()
 
 
new bool IsString ()
 
 
new bool IsUndefined ()
 
 
new bool IsValid ()
 
 
new bool IsVariant ()
 
 
new bool LessThan (QScriptValue other)
 
 
new long ObjectId ()
 
new QScriptValue Property (QScriptString name)
 
 
new QScriptValue Property (QScriptString name, QScriptValue.ResolveFlag mode)
 
 
new QScriptValue Property (string name)
 
 
new QScriptValue Property (uint arrayIndex)
 
 
new QScriptValue Property (string name, QScriptValue.ResolveFlag mode)
 
 
new QScriptValue Property (uint arrayIndex, QScriptValue.ResolveFlag mode)
 
 
new QScriptValue.PropertyFlag PropertyFlags (QScriptString name)
 
 
new QScriptValue.PropertyFlag PropertyFlags (QScriptString name, QScriptValue.ResolveFlag mode)
 
 
new QScriptValue.PropertyFlag PropertyFlags (string name)
 
 
new QScriptValue.PropertyFlag PropertyFlags (string name, QScriptValue.ResolveFlag mode)
 
 
new void SetProperty (QScriptString name, QScriptValue value)
 
 
new void SetProperty (QScriptString name, QScriptValue value, QScriptValue.PropertyFlag flags)
 
 
new void SetProperty (string name, QScriptValue value)
 
 
new void SetProperty (uint arrayIndex, QScriptValue value)
 
 
new void SetProperty (string name, QScriptValue value, QScriptValue.PropertyFlag flags)
 
 
new void SetProperty (uint arrayIndex, QScriptValue value, QScriptValue.PropertyFlag flags)
 
 
new bool StrictlyEquals (QScriptValue other)
 
 
new bool ToBool ()
 
 
new bool ToBoolean ()
 
 
new QDateTime ToDateTime ()
 
 
new int ToInt32 ()
 
 
new double ToInteger ()
 
 
new double ToNumber ()
 
 
new QScriptValue ToObject ()
 
 
new QMetaObject ToQMetaObject ()
 
 
new QObject ToQObject ()
 
 
new QRegExp ToRegExp ()
 
 
override string ToString ()
 
 
new ushort ToUInt16 ()
 
 
new uint ToUInt32 ()
 
 
new object ToVariant ()
 
 
new void Dispose ()
 

Protected Member Functions

 QScriptValue (System.Type dummy)
 

Protected Attributes

SmokeInvocation interceptor
 

Properties

new QScriptValue Data [get, set]
 
 
new QScriptValue Prototype [get, set]
 
 
new QScriptValue Scope [get, set]
 
new QScriptClass ScriptClass [get, set]
 
 
virtual System.IntPtr SmokeObject [get, set]
 

Detailed Description

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

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 QVariant, QObject and QMetaObject.

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

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

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

QScriptEngine myEngine;

QScriptValue myObject = myEngine.newObject();

QScriptValue 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 setProperty(). The attributes of a property can be queried by calling the propertyFlags() function. The following code snippet creates a property that cannot be modified by script code:

QScriptValue val(&myEngine, 123);

myObject.setProperty("myReadOnlyProperty", val, QScriptValue::ReadOnly);

If you want to iterate over the properties of a script object, use the QScriptValueIterator class.

Object values have an internal prototype property, which can be accessed with prototype() and 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 property() function will automatically attempt to look up look the property in the prototype() (and in the prototype of the prototype(), and so on), if the object itself does not have the requested property. Note that this prototype-based lookup is not performed by setProperty(); setProperty() will always create the property in the script object itself. For more information, see the QtScript documentation.

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

Use equals(), strictlyEquals() and lessThan() to compare a QScriptValue to another.

Object values can have custom data associated with them; see the setData() and 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 QScriptClass) to store a C++ type that contains the "native" object data.

Note that a QScriptValue for which isObject() is true only carries a reference to an actual object; copying the 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 QScriptValueIterator in C++.

See also QScriptEngine and QScriptValueIterator.

Member Enumeration Documentation

This enum describes the attributes of a property.

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

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

Enumerator:
KeepExistingFlags 

This value is used to indicate to setProperty() that the property's flags should be left unchanged. If the property doesn't exist, the default flags (0) will be used.

PropertyGetter 

The property is defined by a function which will be called to get the property value.

PropertySetter 

The property is defined by a function which will be called to set the property value.

QObjectMember 
ReadOnly 

The property is read-only. Attempts by Qt Script code to write to the property will be ignored.

SkipInEnumeration 

The property is not to be enumerated by a for-in enumeration.

Undeletable 

Attempts by Qt Script code to delete the property will be ignored.

UserRange 

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

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.

Enumerator:
ResolveFull 
ResolveLocal 

Only check the object's own properties.

ResolvePrototype 

Check the object's own properties first, then search the prototype chain. This is the default.

ResolveScope 

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

Enumerator:
NullValue 

A null value.

UndefinedValue 

An undefined value.

Constructor & Destructor Documentation

QtScript.QScriptValue.QScriptValue ( System.Type  dummy)
protected
QtScript.QScriptValue.QScriptValue ( )

Constructs an invalid QScriptValue.

QtScript.QScriptValue.QScriptValue ( QScriptValue  other)

Constructs a new QScriptValue that is a copy of other.

Note that if other is an object (i.e., 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).

QtScript.QScriptValue.QScriptValue ( QLatin1String  value)

Constructs a new QScriptValue with a string value.

This function was introduced in Qt 4.5.

QtScript.QScriptValue.QScriptValue ( QScriptEngine  engine,
QScriptValue.SpecialValue  val 
)

Constructs an invalid QScriptValue.

QtScript.QScriptValue.QScriptValue ( QScriptEngine  engine,
bool  val 
)

Constructs an invalid QScriptValue.

QtScript.QScriptValue.QScriptValue ( QScriptEngine  engine,
int  val 
)

Constructs an invalid QScriptValue.

QtScript.QScriptValue.QScriptValue ( QScriptEngine  engine,
uint  val 
)

Constructs an invalid QScriptValue.

QtScript.QScriptValue.QScriptValue ( QScriptEngine  engine,
double  val 
)

Constructs an invalid QScriptValue.

QtScript.QScriptValue.QScriptValue ( QScriptEngine  engine,
string  val 
)

Constructs an invalid QScriptValue.

QtScript.QScriptValue.QScriptValue ( QScriptValue.SpecialValue  value)

Constructs a new QScriptValue with a special value.

This function was introduced in Qt 4.5.

QtScript.QScriptValue.QScriptValue ( bool  value)

Constructs a new QScriptValue with a boolean value.

This function was introduced in Qt 4.5.

QtScript.QScriptValue.QScriptValue ( int  value)

Constructs a new QScriptValue with a number value.

This function was introduced in Qt 4.5.

QtScript.QScriptValue.QScriptValue ( uint  value)

Constructs an invalid QScriptValue.

QtScript.QScriptValue.QScriptValue ( double  value)

Constructs an invalid QScriptValue.

QtScript.QScriptValue.QScriptValue ( string  value)

Constructs a new QScriptValue with a string value.

This function was introduced in Qt 4.5.

Member Function Documentation

new QScriptValue QtScript.QScriptValue.Call ( )

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

If this QScriptValue is not a function, call() does nothing and returns an invalid QScriptValue.

Note that if thisObject is not an object, the global object (see QScriptEngine::globalObject()) will be used as the `this' object.

Calling call() can cause an exception to occur in the script engine; in that case, call() returns the value that was thrown (typically an Error object). You can call QScriptEngine::hasUncaughtException() to determine if an exception occurred.

QScriptEngine engine;

engine.evaluate("function fullName() { return this.firstName + ' ' + this.lastName; }");

engine.evaluate("somePerson = { firstName: 'John', lastName: 'Doe' }");

QScriptValue global = engine.globalObject();

QScriptValue fullName = global.property("fullName");

QScriptValue who = global.property("somePerson");

qDebug() << fullName.call(who).toString(); // "John Doe"

engine.evaluate("function cube(x) { return x * x * x; }");

QScriptValue cube = global.property("cube");

QScriptValueList args;

args << 3;

qDebug() << cube.call(QScriptValue(), args).toNumber(); // 27

See also construct().

new QScriptValue QtScript.QScriptValue.Call ( QScriptValue  thisObject)

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

If this QScriptValue is not a function, call() does nothing and returns an invalid QScriptValue.

Note that if thisObject is not an object, the global object (see QScriptEngine::globalObject()) will be used as the `this' object.

Calling call() can cause an exception to occur in the script engine; in that case, call() returns the value that was thrown (typically an Error object). You can call QScriptEngine::hasUncaughtException() to determine if an exception occurred.

QScriptEngine engine;

engine.evaluate("function fullName() { return this.firstName + ' ' + this.lastName; }");

engine.evaluate("somePerson = { firstName: 'John', lastName: 'Doe' }");

QScriptValue global = engine.globalObject();

QScriptValue fullName = global.property("fullName");

QScriptValue who = global.property("somePerson");

qDebug() << fullName.call(who).toString(); // "John Doe"

engine.evaluate("function cube(x) { return x * x * x; }");

QScriptValue cube = global.property("cube");

QScriptValueList args;

args << 3;

qDebug() << cube.call(QScriptValue(), args).toNumber(); // 27

See also construct().

new QScriptValue QtScript.QScriptValue.Call ( QScriptValue  thisObject,
QScriptValue  arguments 
)

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

If this QScriptValue is not a function, call() does nothing and returns an invalid QScriptValue.

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

Note that if 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:

QScriptValue myNativeFunction(QScriptContext *ctx, QScriptEngine *)

{

QScriptValue otherFunction = ...;

return otherFunction.call(ctx->thisObject(), ctx->argumentsObject());

}

See also construct() and QScriptContext::argumentsObject().

new QScriptValue QtScript.QScriptValue.Call ( QScriptValue  thisObject,
System.Collections.Generic.List< QScriptValue args 
)

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

If this QScriptValue is not a function, call() does nothing and returns an invalid QScriptValue.

Note that if thisObject is not an object, the global object (see QScriptEngine::globalObject()) will be used as the `this' object.

Calling call() can cause an exception to occur in the script engine; in that case, call() returns the value that was thrown (typically an Error object). You can call QScriptEngine::hasUncaughtException() to determine if an exception occurred.

QScriptEngine engine;

engine.evaluate("function fullName() { return this.firstName + ' ' + this.lastName; }");

engine.evaluate("somePerson = { firstName: 'John', lastName: 'Doe' }");

QScriptValue global = engine.globalObject();

QScriptValue fullName = global.property("fullName");

QScriptValue who = global.property("somePerson");

qDebug() << fullName.call(who).toString(); // "John Doe"

engine.evaluate("function cube(x) { return x * x * x; }");

QScriptValue cube = global.property("cube");

QScriptValueList args;

args << 3;

qDebug() << cube.call(QScriptValue(), args).toNumber(); // 27

See also construct().

new QScriptValue QtScript.QScriptValue.Construct ( )

Creates a new Object and calls this QScriptValue as a constructor, using the created object as the `this' object and passing args 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.

If this QScriptValue is not a function, construct() does nothing and returns an invalid QScriptValue.

Calling construct() can cause an exception to occur in the script engine; in that case, construct() returns the value that was thrown (typically an Error object). You can call QScriptEngine::hasUncaughtException() to determine if an exception occurred.

See also call() and QScriptEngine::newObject().

new QScriptValue QtScript.QScriptValue.Construct ( QScriptValue  arguments)

Creates a new Object and calls this 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.

If this QScriptValue is not a function, construct() does nothing and returns an invalid QScriptValue.

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

See also call(), QScriptEngine::newObject(), and QScriptContext::argumentsObject().

new QScriptValue QtScript.QScriptValue.Construct ( System.Collections.Generic.List< QScriptValue args)

Creates a new Object and calls this QScriptValue as a constructor, using the created object as the `this' object and passing args 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.

If this QScriptValue is not a function, construct() does nothing and returns an invalid QScriptValue.

Calling construct() can cause an exception to occur in the script engine; in that case, construct() returns the value that was thrown (typically an Error object). You can call QScriptEngine::hasUncaughtException() to determine if an exception occurred.

See also call() and QScriptEngine::newObject().

virtual void QtScript.QScriptValue.CreateProxy ( )
virtual
new void QtScript.QScriptValue.Dispose ( )
new QScriptEngine QtScript.QScriptValue.Engine ( )

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

new bool QtScript.QScriptValue.Equals ( QScriptValue  other)

Returns true if this 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 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 String 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 strictlyEquals().

Note that if this QScriptValue or the 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 toString()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).

See also strictlyEquals() and lessThan().

new bool QtScript.QScriptValue.InstanceOf ( QScriptValue  other)

Returns true if this QScriptValue is an instance of other; otherwise returns false.

This 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 QScriptValue.

new bool QtScript.QScriptValue.IsArray ( )

Returns true if this QScriptValue is an object of the Array class; otherwise returns false.

See also QScriptEngine::newArray().

new bool QtScript.QScriptValue.IsBool ( )

Returns true if this QScriptValue is of the primitive type Boolean; otherwise returns false.

This function was introduced in Qt 4.5.

See also toBool().

new bool QtScript.QScriptValue.IsBoolean ( )

Use isBool() instead.

new bool QtScript.QScriptValue.IsDate ( )

Returns true if this QScriptValue is an object of the Date class; otherwise returns false.

See also QScriptEngine::newDate().

new bool QtScript.QScriptValue.IsError ( )

Returns true if this QScriptValue is an object of the Error class; otherwise returns false.

See also QScriptContext::throwError().

new bool QtScript.QScriptValue.IsFunction ( )

Returns true if this QScriptValue is a function; otherwise returns false.

See also call().

new bool QtScript.QScriptValue.IsNull ( )

Returns true if this QScriptValue is of the primitive type Null; otherwise returns false.

See also QScriptEngine::nullValue().

new bool QtScript.QScriptValue.IsNumber ( )

Returns true if this QScriptValue is of the primitive type Number; otherwise returns false.

See also toNumber().

new bool QtScript.QScriptValue.IsObject ( )

Returns true if this QScriptValue is of the Object type; otherwise returns false.

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

See also toObject() and QScriptEngine::newObject().

new bool QtScript.QScriptValue.IsQMetaObject ( )

Returns true if this QScriptValue is a QMetaObject; otherwise returns false.

See also toQMetaObject() and QScriptEngine::newQMetaObject().

new bool QtScript.QScriptValue.IsQObject ( )

Returns true if this QScriptValue is a QObject; otherwise returns false.

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

See also toQObject() and QScriptEngine::newQObject().

new bool QtScript.QScriptValue.IsRegExp ( )

Returns true if this QScriptValue is an object of the RegExp class; otherwise returns false.

See also QScriptEngine::newRegExp().

new bool QtScript.QScriptValue.IsString ( )

Returns true if this QScriptValue is of the primitive type String; otherwise returns false.

See also toString().

new bool QtScript.QScriptValue.IsUndefined ( )

Returns true if this QScriptValue is of the primitive type Undefined; otherwise returns false.

See also QScriptEngine::undefinedValue().

new bool QtScript.QScriptValue.IsValid ( )

Returns true if this QScriptValue is valid; otherwise returns false.

new bool QtScript.QScriptValue.IsVariant ( )

Returns true if this QScriptValue is a variant value; otherwise returns false.

See also toVariant() and QScriptEngine::newVariant().

new bool QtScript.QScriptValue.LessThan ( QScriptValue  other)

Returns true if this 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 QScriptValue or the 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 toString()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).

See also equals().

new long QtScript.QScriptValue.ObjectId ( )
new QScriptValue QtScript.QScriptValue.Property ( QScriptString  name)

Returns the value of this QScriptValue's property with the given name, using the given mode to resolve the property.

If no such property exists, an invalid QScriptValue is returned.

If the property is implemented using a getter function (i.e. has the PropertyGetter flag set), calling 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, property() returns the value that was thrown (typically an Error object).

See also setProperty(), propertyFlags(), and QScriptValueIterator.

new QScriptValue QtScript.QScriptValue.Property ( QScriptString  name,
QScriptValue.ResolveFlag  mode 
)

Returns the value of this QScriptValue's property with the given name, using the given mode to resolve the property.

If no such property exists, an invalid QScriptValue is returned.

If the property is implemented using a getter function (i.e. has the PropertyGetter flag set), calling 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, property() returns the value that was thrown (typically an Error object).

See also setProperty(), propertyFlags(), and QScriptValueIterator.

new QScriptValue QtScript.QScriptValue.Property ( string  name)

Returns the value of this QScriptValue's property with the given name, using the given mode to resolve the property.

If no such property exists, an invalid QScriptValue is returned.

If the property is implemented using a getter function (i.e. has the PropertyGetter flag set), calling 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, property() returns the value that was thrown (typically an Error object).

See also setProperty(), propertyFlags(), and QScriptValueIterator.

new QScriptValue QtScript.QScriptValue.Property ( uint  arrayIndex)

Returns the value of this QScriptValue's property with the given name, using the given mode to resolve the property.

If no such property exists, an invalid QScriptValue is returned.

If the property is implemented using a getter function (i.e. has the PropertyGetter flag set), calling 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, property() returns the value that was thrown (typically an Error object).

See also setProperty(), propertyFlags(), and QScriptValueIterator.

new QScriptValue QtScript.QScriptValue.Property ( string  name,
QScriptValue.ResolveFlag  mode 
)

Returns the value of this QScriptValue's property with the given name, using the given mode to resolve the property.

If no such property exists, an invalid QScriptValue is returned.

If the property is implemented using a getter function (i.e. has the PropertyGetter flag set), calling 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, property() returns the value that was thrown (typically an Error object).

See also setProperty(), propertyFlags(), and QScriptValueIterator.

new QScriptValue QtScript.QScriptValue.Property ( uint  arrayIndex,
QScriptValue.ResolveFlag  mode 
)

Returns the value of this QScriptValue's property with the given name, using the given mode to resolve the property.

If no such property exists, an invalid QScriptValue is returned.

If the property is implemented using a getter function (i.e. has the PropertyGetter flag set), calling 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, property() returns the value that was thrown (typically an Error object).

See also setProperty(), propertyFlags(), and QScriptValueIterator.

new QScriptValue.PropertyFlag QtScript.QScriptValue.PropertyFlags ( QScriptString  name)

Returns the flags of the property with the given name, using the given mode to resolve the property.

See also property().

new QScriptValue.PropertyFlag QtScript.QScriptValue.PropertyFlags ( QScriptString  name,
QScriptValue.ResolveFlag  mode 
)

Returns the flags of the property with the given name, using the given mode to resolve the property.

See also property().

new QScriptValue.PropertyFlag QtScript.QScriptValue.PropertyFlags ( string  name)

Returns the flags of the property with the given name, using the given mode to resolve the property.

See also property().

new QScriptValue.PropertyFlag QtScript.QScriptValue.PropertyFlags ( string  name,
QScriptValue.ResolveFlag  mode 
)

Returns the flags of the property with the given name, using the given mode to resolve the property.

See also property().

new void QtScript.QScriptValue.SetProperty ( QScriptString  name,
QScriptValue  value 
)

Sets the value of this QScriptValue's property with the given name to the given value.

If this QScriptValue is not an object, this function does nothing.

If this 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.

If value is invalid, the property is removed.

If the property is implemented using a setter function (i.e. has the PropertySetter flag set), calling 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 QObject objects.

See also property().

new void QtScript.QScriptValue.SetProperty ( QScriptString  name,
QScriptValue  value,
QScriptValue.PropertyFlag  flags 
)

Sets the value of this QScriptValue's property with the given name to the given value.

If this QScriptValue is not an object, this function does nothing.

If this 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.

If value is invalid, the property is removed.

If the property is implemented using a setter function (i.e. has the PropertySetter flag set), calling 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 QObject objects.

See also property().

new void QtScript.QScriptValue.SetProperty ( string  name,
QScriptValue  value 
)

Sets the value of this QScriptValue's property with the given name to the given value.

If this QScriptValue is not an object, this function does nothing.

If this 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.

If value is invalid, the property is removed.

If the property is implemented using a setter function (i.e. has the PropertySetter flag set), calling 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 QObject objects.

See also property().

new void QtScript.QScriptValue.SetProperty ( uint  arrayIndex,
QScriptValue  value 
)

Sets the value of this QScriptValue's property with the given name to the given value.

If this QScriptValue is not an object, this function does nothing.

If this 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.

If value is invalid, the property is removed.

If the property is implemented using a setter function (i.e. has the PropertySetter flag set), calling 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 QObject objects.

See also property().

new void QtScript.QScriptValue.SetProperty ( string  name,
QScriptValue  value,
QScriptValue.PropertyFlag  flags 
)

Sets the value of this QScriptValue's property with the given name to the given value.

If this QScriptValue is not an object, this function does nothing.

If this 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.

If value is invalid, the property is removed.

If the property is implemented using a setter function (i.e. has the PropertySetter flag set), calling 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 QObject objects.

See also property().

new void QtScript.QScriptValue.SetProperty ( uint  arrayIndex,
QScriptValue  value,
QScriptValue.PropertyFlag  flags 
)

Sets the value of this QScriptValue's property with the given name to the given value.

If this QScriptValue is not an object, this function does nothing.

If this 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.

If value is invalid, the property is removed.

If the property is implemented using a setter function (i.e. has the PropertySetter flag set), calling 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 QObject objects.

See also property().

new bool QtScript.QScriptValue.StrictlyEquals ( QScriptValue  other)

Returns true if this 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 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:

TypeResult

Undefined true

Null true

Boolean 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

String true if both values are exactly the same sequence of characters, false otherwise

Object true if both values refer to the same object, false otherwise

See also equals().

new bool QtScript.QScriptValue.ToBool ( )

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

Note that if this 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 toString()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).

This function was introduced in Qt 4.5.

See also isBool().

new bool QtScript.QScriptValue.ToBoolean ( )

Use toBool() instead.

new QDateTime QtScript.QScriptValue.ToDateTime ( )

Returns a QDateTime representation of this value, in local time. If this QScriptValue is not a date, or the value of the date is NaN (Not-a-Number), an invalid QDateTime is returned.

See also isDate().

new int QtScript.QScriptValue.ToInt32 ( )

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

Note that if this 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 toString()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).

See also toNumber() and toUInt32().

new double QtScript.QScriptValue.ToInteger ( )

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

Note that if this 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 toString()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).

See also toNumber().

new double QtScript.QScriptValue.ToNumber ( )

Returns the number value of this QScriptValue, as defined in ECMA-262 section 9.3, "ToNumber".

Note that if this 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 toString()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).

See also isNumber(), toInteger(), toInt32(), toUInt32(), and toUInt16().

new QScriptValue QtScript.QScriptValue.ToObject ( )

This function is obsolete; use QScriptEngine::toObject() instead.

new QMetaObject QtScript.QScriptValue.ToQMetaObject ( )

If this QScriptValue is a QMetaObject, returns the QMetaObject pointer that the QScriptValue represents; otherwise, returns 0.

See also isQMetaObject().

new QObject QtScript.QScriptValue.ToQObject ( )

If this QScriptValue is a QObject, returns the QObject pointer that the QScriptValue represents; otherwise, returns 0.

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

See also isQObject().

new QRegExp QtScript.QScriptValue.ToRegExp ( )

Returns the QRegExp representation of this value. If this QScriptValue is not a regular expression, an empty QRegExp is returned.

See also isRegExp().

override string QtScript.QScriptValue.ToString ( )

Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".

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

See also isString().

new ushort QtScript.QScriptValue.ToUInt16 ( )

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

Note that if this 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 toString()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).

See also toNumber().

new uint QtScript.QScriptValue.ToUInt32 ( )

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

Note that if this 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 toString()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).

See also toNumber() and toInt32().

new object QtScript.QScriptValue.ToVariant ( )

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

Input TypeResult

Undefined An invalid QVariant.

Null An invalid QVariant.

Boolean A QVariant containing the value of the boolean.

Number A QVariant containing the value of the number.

String A QVariant containing the value of the string.

QVariant Object The result is the QVariant value of the object (no conversion).

QObject Object A QVariant containing a pointer to the QObject.

Date Object A QVariant containing the date value (toDateTime()).

RegExp Object A QVariant containing the regular expression value (toRegExp()).

Array Object The array is converted to a QVariantList. Each element is converted to a QVariant, recursively; cyclic references are not followed.

Object The object is converted to a QVariantMap. Each property is converted to a QVariant, recursively; cyclic references are not followed.

See also isVariant().

Member Data Documentation

SmokeInvocation QtScript.QScriptValue.interceptor
protected

Property Documentation

new QScriptValue QtScript.QScriptValue.Data
getset

Returns the internal data of this QScriptValue object. 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 setData().

This function was introduced in Qt 4.4.

Sets the internal data of this 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 data() function.

This function was introduced in Qt 4.4.

new QScriptValue QtScript.QScriptValue.Prototype
getset

If this QScriptValue is an object, returns the internal prototype (proto property) of this object; otherwise returns an invalid QScriptValue.

If this 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.

new QScriptValue QtScript.QScriptValue.Scope
getset
new QScriptClass QtScript.QScriptValue.ScriptClass
getset

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

This function was introduced in Qt 4.4.

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.

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

This function was introduced in Qt 4.4.

virtual System.IntPtr QtScript.QScriptValue.SmokeObject
getset