How to set dynamic Property for QJSEngine
Unsolved
General and Desktop
-
I would like to add a dynamic properties to the java script function that will be evaluated by a QJSEngine.
QString formula = "_X_*_X_"; //initial value of _X_ is 5 QString jsCode = QString("(function myFunction() {return (%1);})();").arg(formula); QJSValue fun = m_jsengine->evaluate(jsCode); m_jsengine->globalObject().setProperty("_X_",QJSValue(QString("%1").arg(10)); fun.call(); //variable X is not changed to 10
why the set property for the engine does not work here. Does fun.call() will not evaluate the jscode again with the update property? If not then how to tell the engine to take the new value for X instead of the old value.
-
@NewMoon
see QTBUG-38181
It's a known limitation of QJSEngine.
If you can, switch to QScriptEngine (QML).