QListmyList; myList << 1 << 2 << 3 << 4 << 5; QList ::const_iterator i; for (i = myList.constBegin(); i != myList.constEnd(); ++i) { // Do something with *i }
QListThis example creates a QList of strings and adds 4 elements to it. It then creates a const iterator and sets it to point to the last item in the list. It finally retrieves the value of the last item in the list.myList; myList << "apple" << "banana" << "pear" << "kiwi"; QList ::const_iterator i = myList.constEnd() - 1; QString lastItem = *i;