×
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
jimgilmour1 (Talk | contribs)
m (minor format)
jimgilmour1 (Talk | contribs)
m (add code example category)
Line 1: Line 1:
 +
[[Category:Qt]][[Category:How To]][[Category:Code Examples]]
 
{{CodeSnippet
 
{{CodeSnippet
 
|id=
 
|id=
Line 5: Line 6:
 
|category= Qt
 
|category= Qt
 
|subcategory=  
 
|subcategory=  
|creationdate=
+
|creationdate=20-Jun-2010
 
|keywords= Qt, deleteLater
 
|keywords= Qt, deleteLater
 
}}
 
}}

Revision as of 10:40, 21 June 2010

Article Metadata
Compatibility
Platform(s): All
Symbian
Article
Keywords: Qt, deleteLater
Created: (20 Jun 2010)
Last edited: jimgilmour1 (21 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 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()

102 page views in the last 30 days.
×