[Qt-interest] Memory Management in Qt

Ramesh ramesh.bs at robosoftin.com
Tue Oct 26 08:32:35 CEST 2010


Thanks konrad,

Ok, so all the widget by default will have a first parameter as parent, so
if we specify the parent
We don't need to bother about deletion of the widget right..


-----Original Message-----
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Konrad Rosenbaum
Sent: Tuesday, October 26, 2010 11:59 AM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Memory Management in Qt

On Tuesday 26 October 2010, Ramesh wrote:
> What about the Qlistview and QStandardItemModel object?
> Should I delete them in the destructor of widget? Or any other
> alternative is there for it also?

The listview is owned by its parent widget - you do not need to delete it.

The QStandardItemModel takes an optional first parameter: the parent. If it
has a parent it will be deleted automatically when the parent is deleted. I
usually let models be owned by the same widget as the *view it is used by -
this way they are cleaned up together.


	Konrad


-----------------------------------------------
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an intended recipient, please notify the sender and delete all copies. Emails to and from our network may be logged and monitored. This email and its attachments are scanned for virus by our scanners and are believed to be safe. However, no warranty is given that this email is free of malicious content or virus.



More information about the Qt-interest-old mailing list