PDA

View Full Version : QList and garbage collection



zgulser
5th April 2012, 13:30
Hi,

I have;


QObject* obj = new QObject

And I have two seperate lists that hold address of the obj.

I want to ask that, does QList clear, removeAt, removeAll etc. methods deletes the object itself or reference?

If so, how Qt deletes the obj? By keeping reference(s) on it?

Thanks

Lykurg
5th April 2012, 13:36
They are not getting deleted. You have to take care about that yourself. clear() just clears the list. If you also want to delete the stored items see qDeleteAll().

zgulser
5th April 2012, 14:34
So you say only references in the list are being removed?

Well, what qt garbage collector does then? Is there any of it actually?

Lykurg
5th April 2012, 14:38
Yes, and Qt does not have a gc like Java. Qt does only delete the children of a QObject when it gets destroyed.