Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QScriptValue Class Reference

List of all members.

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. isBoolean(), isUndefined()) can be used to test if a value is of a certain type. The methods named toT() (e.g. toBoolean(), 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.

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++.

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

See also:
QScriptEngine, QScriptValueIterator

Definition at line 67 of file qscriptvalue.h.

Public Types

enum  PropertyFlag {
  ReadOnly = 0x00000001, Undeletable = 0x00000002, SkipInEnumeration = 0x00000004, PropertyGetter = 0x00000008,
  PropertySetter = 0x00000010, QObjectMember = 0x00000020, KeepExistingFlags = 0x00000800, UserRange = 0xff000000
enum  ResolveFlag { ResolveLocal = 0x00, ResolvePrototype = 0x01, ResolveScope = 0x02, ResolveFull = ResolvePrototype | ResolveScope }
enum  SpecialValue { NullValue, UndefinedValue }

Public Member Functions

QScriptValue call (const QScriptValue &thisObject, const QScriptValue &arguments)
QScriptValue call (const QScriptValue &thisObject=QScriptValue(), const QScriptValueList &args=QScriptValueList())
QScriptValue construct (const QScriptValue &arguments)
QScriptValue construct (const QScriptValueList &args=QScriptValueList())
QScriptEngineengine () const
bool equals (const QScriptValue &other) const
bool instanceOf (const QScriptValue &other) const
bool isArray () const
bool isBoolean () const
bool isDate () const
bool isError () const
bool isFunction () const
bool isNull () const
bool isNumber () const
bool isObject () const
bool isQMetaObject () const
bool isQObject () const
bool isRegExp () const
bool isString () const
bool isUndefined () const
bool isValid () const
bool isVariant () const
bool lessThan (const QScriptValue &other) const
QScriptValueoperator= (const QScriptValue &other)
QScriptValue property (quint32 arrayIndex, const ResolveFlags &mode=ResolvePrototype) const
QScriptValue property (const QString &name, const ResolveFlags &mode=ResolvePrototype) const
QScriptValue::PropertyFlags propertyFlags (const QString &name, const ResolveFlags &mode=ResolvePrototype) const
QScriptValue prototype () const
QT_ASCII_CAST_WARN_CONSTRUCTOR QScriptValue (QScriptEngine *engine, const char *val)
 QScriptValue (QScriptEngine *engine, const QString &val)
 QScriptValue (QScriptEngine *engine, qsreal val)
 QScriptValue (QScriptEngine *engine, uint val)
 QScriptValue (QScriptEngine *engine, int val)
 QScriptValue (QScriptEngine *engine, bool val)
 QScriptValue (QScriptEngine *engine, SpecialValue val)
 QScriptValue (const QScriptValue &other)
 QScriptValue ()
QScriptValue scope () const
void setProperty (quint32 arrayIndex, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags)
void setProperty (const QString &name, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags)
void setPrototype (const QScriptValue &prototype)
void setScope (const QScriptValue &scope)
bool strictlyEquals (const QScriptValue &other) const
bool toBoolean () const
QDateTime toDateTime () const
qint32 toInt32 () const
qsreal toInteger () const
qsreal toNumber () const
QScriptValue toObject () const
const QMetaObjecttoQMetaObject () const
QObjecttoQObject () const
QRegExp toRegExp () const
QString toString () const
quint16 toUInt16 () const
quint32 toUInt32 () const
QVariant toVariant () const
 ~QScriptValue ()

Private Attributes

QScriptValuePrivate * d_ptr

Related Functions

(Note that these are not member functions.)

qscriptvalue_cast (const QScriptValue &value)

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index