Is there a way to mark a slot or invokable to not give ownership to the qml engine?
-
I have a slot that returns a QObject*. I forgot that QML takes ownership of the object unless you tell the engine that you don't want that ie:
if(m_engine){ m_engine->setObjectOwnership(m_buttonList[index], QQmlEngine::CppOwnership); }This is a pain as I have to pollute my objects to get the engine. What I want is this:
public slots: Q_CPPOWNED QObject* getObject();Some macro or something to mark the slot or invokable. I suppose this is probably not possible as it would need to find the info about the current engine.
-
I have a slot that returns a QObject*. I forgot that QML takes ownership of the object unless you tell the engine that you don't want that ie:
if(m_engine){ m_engine->setObjectOwnership(m_buttonList[index], QQmlEngine::CppOwnership); }This is a pain as I have to pollute my objects to get the engine. What I want is this:
public slots: Q_CPPOWNED QObject* getObject();Some macro or something to mark the slot or invokable. I suppose this is probably not possible as it would need to find the info about the current engine.
-
F fcarney has marked this topic as solved on