Re: clear qlist inside qmap
The lists are cleared as well.
More precisely: each map element is deconstructed, the QList destructor clears the list.
Cheers,
_
Re: clear qlist inside qmap
Hi,
What if elements of inner QList, or values of inner QMap are created with "new" operator like this
Code:
struct SomeStruct {
....
}
QMap<int,QList<SomeStruct*> > myMap;
SomeStruct *s1=new SomeStruct;
SomeStruct *s2=new SomeStruct;
myMap[a].append[s1];
myMap[a].append[s2];
..............
myMap.clear();
So in inner map i have in fact pointers to structure, or to other objects created with "new". Is there "delete" called for each object created with "new" ?
best regards
Marek
Re: clear qlist inside qmap
No, the list clears its contents and the content is pointers, not objects behind them. You can use qDeleteAll() to clear objects behind the pointers:
Code:
QList<SomeStruct*> list;
// ...
qDeleteAll(list);