Add int to QList : QList « Qt « C++






Add int to QList

  

#include <QtCore>
#include <QDebug>

int main() {
  QList<int> intlist;
  intlist << 2 << 5 << 2 << 4 << 2;

  int findings = 0;
  QListIterator<int> it(intlist);

  while (it.findNext(2))
    findings++;
  qDebug() << findings; // output: 3

  while (it.findPrevious(2))
    findings--;
  qDebug() << findings; // : 0

  return 0;
}

   
    
  








Related examples in the same category

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