Trying to execute a small script with a subclass of QObject as a parameter.
QJSEngine jsEngine;
QJSValue arg = jsEngine.newQObject(child);
QJSValue function = jsEngine.evaluate(m_childRestriction);
QJSValue result = function.call(QJSValueList() << arg);
When killing jsEngine, it calls delete for my child object (since newQObject creates it using JavaScriptOwnership). How to avoid this, how to change ownership of arg?
Script is simple:
function(device) {
return device.m_place >=0 && device.m_place < 16;
}
UPD:
It can be called QQmlEngine::setObjectOwnership(child, QQmlEngine::CppOwnership);for an object, since it is a static function. This is just not clear from the help. Think it should be in QJSEngine.
source
share