Trying to perform small script with subclassed QObject as parameter.
QJSEngine jsEngine;
QJSValue arg = jsEngine.newQObject(child); // Child it's subclassed QObject
QJSValue function = jsEngine.evaluate(m_childRestriction);
QJSValue result = function.call(QJSValueList() << arg);
On destroying jsEngine, it calls delete for my child object (as newQObject creates it with JavaScriptOwnership). How to avoid it, how to change ownership for arg?
Script is simple:
function(device) {
return device.m_place >=0 && device.m_place < 16;
}
UPD:
It is possible to call QQmlEngine::setObjectOwnership(child, QQmlEngine::CppOwnership);
for the object as it is the static function. It just not clear from the help. Think it is suppose to be in QJSEngine
also.
It is possible to call QQmlEngine::setObjectOwnership(child, QQmlEngine::CppOwnership); for the object as it is the static function. It just not clear from the help. Think it is suppose to be in QJSEngine also.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With