×
Namespaces

Variants
Actions
(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
gnuton (Talk | contribs)
(Created page with '{{CodeSnippet |id= |platform= All |devices= |category= Qt |subcategory= |creationdate= |keywords= Qt }} In order to delete a QObject-derived class from one of its own methods, …')
 
gnuton (Talk | contribs)
m
Line 6: Line 6:
 
|subcategory=  
 
|subcategory=  
 
|creationdate=
 
|creationdate=
|keywords= Qt
+
|keywords= Qt, deleteLater
 
}}
 
}}
  

Revision as of 14:26, 20 June 2010

Article Metadata
Compatibility
Platform(s): All
Symbian
Article
Keywords: Qt, deleteLater
Created: ()
Last edited: gnuton (20 Jun 2010)

In order to delete a QObject-derived class from one of its own methods, developers have to use

deleteLater();

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 problems if a signal or a method call more than one time QObject::deleteLater()

Beginner developers sometime 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.

78 page views in the last 30 days.
×