(Difference between revisions)

How to delete a QObject derived class from within one of its own methods

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Addition to article of: Category:MeeGo Category:Symbian. (Add platform categories))
hamishwillee (Talk | contribs)
m (Text replace - "Category:MeeGo" to "Category:MeeGo Harmattan")
Line 34: Line 34:
Qt 4.6 [http://doc.qt.nokia.com/4.6/qobject.html#deleteLater deleteLater()]
Qt 4.6 [http://doc.qt.nokia.com/4.6/qobject.html#deleteLater deleteLater()]
[[Category:Qt]][[Category:MeeGo]] [[Category:Symbian]]
[[Category:Qt]][[Category:MeeGo Harmattan]] [[Category:Symbian]]

Revision as of 13:53, 13 June 2012

Article Metadata
Platform(s): All
Keywords: Qt, deleteLater
Created: gnuton (20 Jun 2010)
Last edited: hamishwillee (13 Jun 2012)

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

delete this;

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()

80 page views in the last 30 days.