I have a subclass of a QObject
which I can already create in QtScript using var x = new Test();
I made a constructor function and registered it using QScriptEngine::newFunction
and QScriptEngine::newQMetaObject
like this:
QScriptValue construct_Test(QScriptContext *context, QScriptEngine *engine)
{
Test * ptr = new Test();
return engine->newQObject(ptr);
}
....
QScriptValue constructor = pEngine->newFunction(construct_Test);
QScriptValue metaObject = pEngine->newQMetaObject(&Test::staticMetaObject, constructor);
pEngine->globalObject().setProperty("Test", metaObject);
I manage the object lifetime by myself (pointers to objects are stored in a static member of Test).
How can I make delete x;
in QtScript
delete
the underlying C++ object? I know about x.deleteLater();
(slot from QObject
) but I can't use it.