[Qt-interest] How does QT release its memory?
Leonardo Bispo
leonardo.bispo at corp.orolix.com
Sat Dec 13 15:29:08 CET 2008
Each object is responsible for delete his parents!!!
This is because you dont know when the object should be deleted.
So, when you delete an object, all childrens will be deleted on cascade.
QObject Documentation:
QObject::~QObject () [virtual]
Destroys the object, deleting all its child objects.
All signals to and from the object are automatically disconnected, and any pending posted events for the object are removed from the event queue. However, it is often safer to use deleteLater() rather than deleting a QObject subclass directly.
Warning: All child objects are deleted. If any of these objects are on the stack or global, sooner or later your program will crash. We do not recommend holding pointers to child objects from outside the parent. If you still do, the destroyed() signal gives you an opportunity to detect when an object is destroyed.
Warning: Deleting a QObject while pending events are waiting to be delivered can cause a crash. You must not delete the QObject directly if it exists in a different thread than the one currently executing. Use deleteLater() instead, which will cause the event loop to delete the object after all pending events have been delivered to it.
See also deleteLater().
Best Regards,
Leonardo Bispo de Oliveira
Desenvolvimento de Sistemas - Analista Desenvolvedor
Tel: +55 11 5508 5887, +55 11 2122 0312
Fax: +55 11 5508 5880
http://www.orolix.com.br - leonardo.bispo at corp.orolix.com
Orolix. Você NAVEGA, a gente PAGA !!!
-----Mensagem original-----
De: qt-interest-bounces at trolltech.com em nome de ???
Enviada: sáb 13/12/2008 05:11
Para: qt-interest at trolltech.com
Assunto: [Qt-interest] How does QT release its memory?
Hi all,
I am new to qt, and I have read some tutorials.
I found all of then use new to create objects, but never use delete to release.
Why?
Tuvok
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20081213/76af73e1/attachment.html
More information about the Qt-interest-old
mailing list