Boolean in Qt Script
-
Hellow, how can i add boolean to script engine, i try:
@bool isDegrees;
QScriptValue scriptIsDegrees = scriptEngine.newObject(&isDegrees);@
But i get this error:bq. Error 1 error C2664: QScriptValue QScriptEngine:: newObject (QScriptClass *, const QScriptValue &): can not convert parameter 1 from 'bool *' in 'QScriptClass *' c: \ Users \ ruzik \ Documents \ Visual Studio 2008 \ Projects \ RizekMath \ RizekMath \ Widges \ RCalculatorWidget \ RCalculatorWidget.cpp 37
In advance thank you for your help!
[edit : fixed formatting, Eddy]
-
Take another look at the "QScriptEngine::newObject()":http://doc.qt.nokia.com/4.7/qscriptengine.html#newObject-2 signature.
-
I dont find any information to solve problem, but i find way how can i do it:
@ QScriptValue scriptIsDegrees(&scriptEngine,false);
scriptEngine.globalObject().setProperty("isDegrees", scriptIsDegrees);@
But why was my first way wrong?
Please explain me more -
bq. QScriptValue QScriptEngine:: newObject (QScriptClass *, const QScriptValue &): can not convert parameter 1 from ‘bool *’ in ‘QScriptClass *
Meaning :
There is no function in the QScriptEngine class which takes as it's first parameter a pointer to a boolean. The compiler tries to convert it to one of the existing signatures, but doesn't succeed. -
Perhaps this constructor is not documented, but in the header file, it exists:
@
QScriptValue();
~QScriptValue();
QScriptValue(const QScriptValue &other);
QScriptValue(QScriptEngine *engine, SpecialValue val);
QScriptValue(QScriptEngine *engine, bool val);
QScriptValue(QScriptEngine *engine, int val);
QScriptValue(QScriptEngine *engine, uint val);
QScriptValue(QScriptEngine *engine, qsreal val);
QScriptValue(QScriptEngine *engine, const QString &val);
@EDIT: I looked at the docs, these constructors are obsolete...