Search code examples
qtmemory-managementqlist

QList and delete


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?


Solution

  • You could use qDeleteAll:

    qDeleteAll(lstMdls);
    
    lstMdls.clear();