http://doc.qt.nokia.com/4.4/qtscript.html#default-conversion-from-qt-script-to-c
C++ Type |
Default Conversion |
bool |
|
int |
|
uint |
|
float |
float(QScriptValue::toNumber()) |
double |
|
short |
short(QScriptValue::toInt32()) |
ushort |
|
char |
char(QScriptValue::toInt32()) |
uchar |
unsigned char(QScriptValue::toInt32()) |
qlonglong |
qlonglong(QScriptValue::toInteger()) |
qulonglong |
qulonglong(QScriptValue::toInteger()) |
QScriptValue::toDateTime().date() |
|
If the QScriptValue is a string, the result is the first character of the string, or a null QChar if the string is empty; otherwise, the result is a QCharconstructed from the unicode obtained by converting the QScriptValue to a ushort. |
|
If the QScriptValue is an array, the result is a QStringList constructed from the result of QScriptValue::toString() for each array element; otherwise, the result is an empty QStringList. |
|
If the QScriptValue is an array, the result is a QVariantList constructed from the result of QScriptValue::toVariant() for each array element; otherwise, the result is an empty QVariantList. |
|
If the QScriptValue is an object, the result is a QVariantMap with a (key, value) pair of the form (propertyName, propertyValue.toVariant()) for each property, using QScriptValueIterator to iterate over the object's properties. |
|
If the QScriptValue is an array, the result is a QObjectList constructed from the result of QScriptValue::toQObject() for each array element; otherwise, the result is an empty QObjectList. |
|
QList<int> |
If the QScriptValue is an array, the result is a QList<int> constructed from the result of QScriptValue::toInt32() for each array element; otherwise, the result is an empty QList<int>. |
Additionally, QtScript will handle the following cases:
The following table describes the default behavior when a QScriptValue is constructed from a C++ type:
C++ Type |
Default Construction |
void |
|
bool |
QScriptValue(engine, value) |
int |
QScriptValue(engine, value) |
uint |
QScriptValue(engine, value) |
float |
QScriptValue(engine, value) |
double |
QScriptValue(engine, value) |
short |
QScriptValue(engine, value) |
ushort |
QScriptValue(engine, value) |
char |
QScriptValue(engine, value) |
uchar |
QScriptValue(engine, value) |
QScriptValue(engine, value) |
|
qlonglong |
QScriptValue(engine, qsreal(value)). Note that the conversion may lead to loss of precision, since not all 64-bit integers can be represented using the qsreal type. |
qulonglong |
QScriptValue(engine, qsreal(value)). Note that the conversion may lead to loss of precision, since not all 64-bit unsigned integers can be represented using the qsreal type. |
QScriptValue(this, value.unicode()) |
|
QScriptEngine::newDate(value) |
|
QScriptEngine::newDate(value) |
|
QScriptEngine::newRegExp(value) |
|
QScriptEngine::newQObject(value) |
|
QScriptEngine::newQObject(value) |
|
QScriptEngine::newVariant(value) |
|
A new script array (created with QScriptEngine::newArray()), whose elements are created using the QScriptValue(QScriptEngine *, QString) constructor for each element of the list. |
|
A new script array (created with QScriptEngine::newArray()), whose elements are created using QScriptEngine::newVariant() for each element of the list. |
|
A new script object (created with QScriptEngine::newObject()), whose properties are initialized according to the (key, value) pairs of the map. |
|
A new script array (created with QScriptEngine::newArray()), whose elements are created using QScriptEngine::newQObject() for each element of the list. |
|
QList<int> |
A new script array (created with QScriptEngine::newArray()), whose elements are created using the QScriptValue(QScriptEngine *, int) constructor for each element of the list. |
Other types (including custom types) will be wrapped using QScriptEngine::newVariant(). For null pointers of any type, the result is QScriptEngine::nullValue().
Created with the Personal Edition of HelpNDoc: Easily create iPhone documentation