QList and delete

kiriloff picture kiriloff · Jul 19, 2012 · Viewed 14k times · Source

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?

Answer

sgibb picture sgibb · Jul 19, 2012

You could use qDeleteAll:

qDeleteAll(lstMdls);

lstMdls.clear();