I have a widgets application. I am trying to implement scripting in this application.
The user will create a script using javascript which will be executed on pressing a QPushButton.
The script is expected to be of the form:
I am trying to use QJSEngine class. How the evaluation of script is to be done?Code:
function drawCircle() { center(10, 10); radius(10); }
I have tried the following code snippet in the application:
Code:
QJSValue function = jsEngine->evaluate("function drawCircle() {center(x, y); radius(r);}"); QJSValueList args; args << 1; QJSValue result = function.call(args); int rslt = result.toInt(); qDebug() << rslt;
Is this the right way to add scripting to the application? Please enlighten me on this.