In my Qt application, all controls of a dialog are accessible to scripts using QtScript. To do this I use the newQObject method of QScriptEngine, like:
QScriptValue btn = scriptEngine->newQObject(okBtn, QScriptEngine::QtOwnership);
controls.setProperty("okButton", btn, QScriptValue::ReadOnly);
E.g. I can now do this in a script:
dialog.controls.okButton.setEnabled(false);
This works fine as far as the invoked method (setEnabled) of the published control (okButton) is marked as public slot in the objects class. Unfortunately many of the methods I want to be able to call from script are only defined in normal public scope.
One way to solve this would be to derive a new class from each Qt UI element, that overrides those methods as public slots. But this implies big overhead in coding and maintenance, which is not desirable in this situation.
Is there a way to tell the script engine to make normal public functions available by default?