QList is a container class in Qt that provides a list of items. It is similar to the std::vector container in C++, but with additional features such as fast and efficient insertion and removal of elements.
Here are some code examples using QList:
1. Creating a QList of integers:
QList myList;
myList << 1 << 2 << 3;
In this example, we create a QList named `myList` and add three integers to it using the `<<` operator.
2. Iterating over a QList:
foreach (int item, myList)
{
qDebug() << item;
}
This code iterates over each item in the `myList` QList and prints it to the debug console using the `qDebug()` function.
3. Sorting a QList:
myList.sort();
This code sorts the items in the `myList` QList in ascending order.
QList is part of the Qt Core library package.
C++ (Cpp) QList - 30 examples found. These are the top rated real world C++ (Cpp) examples of QList extracted from open source projects. You can rate examples to help us improve the quality of examples.