Details
-
Suggestion
-
Resolution: Invalid
-
P3: Somewhat important
-
4.3.4
-
None
Description
It can be made easier to register a self written QObject type into a QScriptEngine. Below are some template functions to simplify this task. Eventually something similar can be integrated as macro or convenience function in further Qt versions.
// template QObject factory callback function
template<class T> QScriptValue scriptConstructorCallback(QScriptContext* context, QScriptEngine* engine)
// register given template parameter as custom type in given script engine
template<class T> void registerScriptType(QScriptEngine& engine, const QString* constructorName = 0)
...
class MyType : public QObject
;
// register custom type
QScriptEngine engine;
registerScriptType<MyType>(engine);