Revision as of 04:17, 11 October 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Platform(s): All
Keywords: Qt, deleteLater
Created: gnuton (20 Jun 2010)
Last edited: hamishwillee (11 Oct 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()

This page was last modified on 11 October 2012, at 04:17.
64 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.