Qt-interest Archive, March 2007
QList::clear() doubt
Message 1 in thread
Hi everyone! I have a doubt about QList::clear()
Supose I have a QList like:
QList<MyClass*> myClassList;
Now, I fill this list with a lot of instances of pointers to MyClass.
If I call myClassList.clear(), it would call the proper deletes? Or in this
case I should do it by hand?
Forgive me if this is a too stupid/simple/put_your_adjective_here question,
but I already read the doc and couldn't find something that explains it.
Regards, Lisandro.
--
[ signature omitted ]
Message 2 in thread
On Thursday 29 March 2007 04:50, Lisandro Damián Nicanor Pérez Meyer wrote:
> Supose I have a QList like:
>
> QList<MyClass*> myClassList;
>
> Now, I fill this list with a lot of instances of pointers to MyClass.
> If I call myClassList.clear(), it would call the proper deletes? Or in this
> case I should do it by hand?
QList does not any pointers, so you should do it yourself. This is what the
qDeleteAll() function does, so doing this is very easy:
qDeleteAll(myClassList);
myClassList.clear();
:)
--
[ signature omitted ]
Message 3 in thread
El Jueves 29 Marzo 2007 02:49, escribió:
> On Thursday 29 March 2007 04:50, Lisandro Damián Nicanor Pérez Meyer wrote:
> > Supose I have a QList like:
> >
> > QList<MyClass*> myClassList;
> >
> > Now, I fill this list with a lot of instances of pointers to MyClass.
> > If I call myClassList.clear(), it would call the proper deletes? Or in
> > this case I should do it by hand?
>
> QList does not any pointers, so you should do it yourself. This is what the
> qDeleteAll() function does, so doing this is very easy:
>
> qDeleteAll(myClassList);
> myClassList.clear();
>
> :)
Thank you all for your answers!!!
Regards, Lisandro
--
[ signature omitted ]