S
S
sv112017-01-08 22:45:14
Qt
sv11, 2017-01-08 22:45:14

Why is there no access to the children of QObjects in the scripting engine via QJSEngine?

Good day to all!
We have a widget and want to make it, along with its child objects, available in the scripting engine. For example, the widget myWidget with the button myButton.
This is how it all works:

QScriptEngine engine;
QWidget *myWidget = new QWidget;
QScriptValue objectValue = engine.newQObject(myWidget);
engine.globalObject().setProperty("myWidget", objectValue);

myWidget.myButton.objectName = "Another name" // Ok

However, if you create a scripting engine through QJSEngine (instead of QScriptEngine), the myButton property of the myWidget object is not available. Why?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question