[Qt-interest] How does QT release its memory?

techsgin techsgin at gmail.com
Sat Dec 13 15:02:47 CET 2008


Hi ???

 

For non “QObject” the rules are standard c++ nothing changed.

For “QObject” you can, but you better use MyObject->deleteLater()

 

void QObject::deleteLater ()   [slot]

 

Schedules this object for deletion.

 

The object will be deleted when control returns to the event loop. If the event loop is not running when this function is called (e.g. deleteLater() is called on an object before QCoreApplication::exec()), the object will be deleted once the event loop is started.

Note that entering and leaving a new event loop (e.g., by opening a modal dialog) will not perform the deferred deletion; for the object to be deleted, the control must return to the event loop from which deleteLater() was called.

 

Note: It is safe to call this function more than once; when the first deferred deletion event is delivered, any pending events for the object are removed from the event queue.

 

See also destroyed() and QPointer.

 

Regards

TechSgin

 

 

  _____  

From: ??? [mailto:leecomcn at hotmail.com] 
Sent: Saturday, December 13, 2008 10:58 AM
To: techsgin; 'Tim W'
Cc: qt-interest at trolltech.com
Subject: Re: [Qt-interest] How does QT release its memory?

 

Hi,

Can I still use delete to reclaim memory manually?

 

Tuvok

 

From: techsgin <mailto:techsgin at gmail.com>  

Sent: Saturday, December 13, 2008 9:50 AM

To: 'Tim W' <mailto:timpie.w at gmail.com>  ; '李亮亮' <mailto:leecomcn at hotmail.com>  

Cc: qt-interest at trolltech.com 

Subject: RE: [Qt-interest] How does QT release its memory?

 

Hi Tim

 

 

Using Qt assistant Look for “Object Trees and Object Ownership”

For more information in regards to Objects and threads see “Thread Support in Qt”   in section “Per-Thread Event Loop” 

 

Regards

TechSgin

 

  _____  

From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Tim W
Sent: Saturday, December 13, 2008 10:40 AM
To: ???
Cc: qt-interest at trolltech.com
Subject: Re: [Qt-interest] How does QT release its memory?

 

 

<quote http://doc.trolltech.com/4.4/objecttrees.html >

 <http://doc.trolltech.com/4.4/qobject.html> QObjects organize themselves in object trees. When you create a  <http://doc.trolltech.com/4.4/qobject.html> QObject with another object as parent, it's added to the parent's  <http://doc.trolltech.com/4.4/qobject.html#children> children() list, and is deleted when the parent is ....  

</quote>

 

Cheers,

Tim

On Sat, Dec 13, 2008 at 8:11 AM, 李亮亮 <leecomcn at hotmail.com> wrote:

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


_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




-- 
An Apple a day keeps Windows away

ACCU - http://www.accu.org - Professionalism in Programming.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20081213/f279dd4e/attachment.html 


More information about the Qt-interest-old mailing list