Delete all elements in a QList : QList « Qt « C++






Delete all elements in a QList

  

#include <QtGui>
#include <QDebug>

int main(int argc, char * argv[]) {
  QApplication app(argc, argv);
  QList<QWidget* > widgetList;
  for (int i = 1; i < 10; i++)
  {
     widgetList.append(new QWidget);

  }
  qDeleteAll(widgetList.begin(), widgetList.end());
  widgetList.clear();
  widgetList.append(new QWidget);
  return 0;
}

   
    
  








Related examples in the same category

1.Add int to QList
2.Append and insert into QList
3.Foreach loop with QList
4.Sorting QList
5.Find next element in a QList with QMutableListIterator
6.QList of QString
7.Filling Data Structures
8.Quick sort QList
9.QList of int