Boolean in Qt Script
-
wrote on 27 Sept 2011, 18:07 last edited by
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]
-
wrote on 27 Sept 2011, 18:14 last edited by
Take another look at the "QScriptEngine::newObject()":http://doc.qt.nokia.com/4.7/qscriptengine.html#newObject-2 signature.
-
wrote on 27 Sept 2011, 18:33 last edited by
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 -
wrote on 27 Sept 2011, 18:44 last edited by
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. -
wrote on 27 Sept 2011, 18:46 last edited by
I undrestund it, i cant understund how can i do right
-
wrote on 27 Sept 2011, 18:46 last edited by
I need to add bool value to script
-
wrote on 27 Sept 2011, 18:47 last edited by
Hu Ruzik,
your first post had the bug, that you used a function, that wanted a QScriptClass pointer as first parameter:
@
QScriptEngine::newObject ( QScriptClass * scriptClass, const QScriptValue & data = QScriptValue() )
@ -
wrote on 27 Sept 2011, 18:55 last edited by
Why when i write this:
@QScriptValue scriptIsDegrees(&scriptEngine,isDegrees);@
It is all right, but i dont find this constructor in assist -
wrote on 27 Sept 2011, 19:26 last edited by
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...
-
wrote on 28 Sept 2011, 09:59 last edited by
If i do it:
@QScriptValue(QScriptEngine *engine, bool val);@
I am add in script only variable not value, how can i add value -
wrote on 28 Sept 2011, 10:13 last edited by
I need to do something like this
@QScriptValue(QScriptEngine *engine, &bool val);@
7/11