Memory management in Qt Quick
-
Hi everyone!
Maybe my question is stupid but I can't understand how works QML properties with memory. I have the C++ object which has pointer to object as field:
@Q_PROPERTY(MslElement* newElement READ getNewElement NOTIFY newElementChanged)
//Getter
inline MslElement* getNewElement(){return m_newElement;}//private class field
private:
MslElement* m_newElement;
@The question: When I try to use this property like this:
@property MslElement propertyElement: appRoot.manager.newElement@new object propertyElement will have a pointer to source object or it will be a new copy of source object.
Thanks for the help.
P.S. Where I can find some books or tutorial for memory management? Thanks.
-
I am not sure, but I think in this case only the reference will be kept. QObject subclasses are not copyable, after all :)
For a real in-depth analysis of QML engine, please read this splendid "KDAB blog":http://www.kdab.com/qml-engine-internals-part-1-qml-file-loading/ (there are several more parts in the series, I highly recommend reading them all).
-
[quote author="sierdzio" date="1388755942"]I am not sure, but I think in this case only the reference will be kept. QObject subclasses are not copyable, after all :)
For a real in-depth analysis of QML engine, please read this splendid "KDAB blog":http://www.kdab.com/qml-engine-internals-part-1-qml-file-loading/ (there are several more parts in the series, I highly recommend reading them all).[/quote]
Thanks for the link! I'll look it!