engine->newQObject(new MyQObject(), QScriptEngine::ScriptOwnership);
engine->newQObject(new MyQObject(), QScriptEngine::ScriptOwnership);
To copy to clipboard, switch view to plain text mode
Probably you will want to call the constructor from script as well?
c++:
QScriptValue myQObjectConstructor(QScriptContext *context, QScriptEngine *engine)
{
// let the engine manage the new object's lifetime.
return engine->newQObject(new MyQObject(), QScriptEngine::ScriptOwnership);
}
scripting->globalObject().setProperty("MyQObject", scripting->newFunction(myQObjectConstructor));
script:
..
var q = new MyQObject();
..
c++:
QScriptValue myQObjectConstructor(QScriptContext *context, QScriptEngine *engine)
{
// let the engine manage the new object's lifetime.
return engine->newQObject(new MyQObject(), QScriptEngine::ScriptOwnership);
}
scripting->globalObject().setProperty("MyQObject", scripting->newFunction(myQObjectConstructor));
script:
..
var q = new MyQObject();
..
To copy to clipboard, switch view to plain text mode
Carefully read through http://doc.trolltech.com/latest/scripting.html
It took me several times :->
Johannes
Bookmarks