Automatic deletion of QObjects
-
In my application, I am currently doing the deletion of QObjects myself (too much of traditional C++ history perhaps...). I would however like to introduce undo/redo functionality in my application and from the undo example that comes with Qt (http://doc.qt.io/qt-5/qtwidgets-tools-undo-example.html), I understand that the QObjects (in this case diagram items) are not really destroyed but only removed from the scene on a delete action by the user. By keeping the diagram item in memory, the action can be undone. As I intend to limit the undo stack size, I would like to have the objects destroyed at the moment that the stack size limit is reached. So, my question is actually: will QObjects be destroyed automatically if there are no references to them anymore (with or without having a parent)?
-
Hi,
If the objects don't have any parent then no.