I have a QList
with pointers to objects with class type Model
. I would like to delete appropriately this QList
after it has being used. I know Qt philosophy is to avoid C-style memory management. How do I delete
this QList
?
You could use qDeleteAll:
qDeleteAll(lstMdls);
lstMdls.clear();
Unihedron
As seen from an earlier revision, this was OP's approach:
QList<Model*>lstMdls;
get Data(lstMdls);
/*
* Do other things
*/
for(int i=0;i<lstMlds.size();i++)
{
delete lstMdls.at(i);
}
来源:https://stackoverflow.com/questions/11555630/qlist-and-delete