How to delete a QObject derived class from within one of its own methods
In order to delete a QObject-derived class from one of its own methods, developers have to use
Since this is a public slot, it can be connected to a signal or it can be just called in any method of the class.
There are no problem if a signal or a method calls more than one time QObject::deleteLater()
Beginner developers sometimes use
and this is dangerous since the Qt event loop could invoke a method of the deleted class. Hence, the application or library will crash.
- Related Qt Documentation link
Qt 4.6 deleteLater()