#include#include int main() { QValueList myList; // create an empty list of integers // add values to the list myList << 1 << 2 << 3 << 4 << 5; // iterate over the list and print the values for(QValueList ::iterator it = myList.begin(); it != myList.end(); ++it) { std::cout << *it << std::endl; } return 0; }
#includeThis example demonstrates the sorting of a QValueList containing strings using the std::sort algorithm. The QValueList class is part of the QtCore library in the Qt Framework.#include #include int main() { QValueList myList; myList << "apple" << "banana" << "cherry" << "date" << "elderberry"; std::sort(myList.begin(), myList.end()); // sort the list in alphabetical order for(QValueList ::iterator it = myList.begin(); it != myList.end(); ++it) { std::cout << *it << std::endl; } return 0; }