QListnumbers {1, 2, 3, 4, 5}; int size = numbers.size(); // size == 5
QListThis example shows how to iterate through a QList using a for loop and retrieve each element. The qDebug() function from the Qt library is also used to print the elements to the console. Package library: Qt Library.fruits {"apple", "banana", "strawberry"}; for (int i = 0; i < fruits.size(); ++i) { qDebug() << fruits[i]; }