If I execute the following code:
QList<int> l;
QList<int>::const_iterator lI;
l.append(1);
l.append(2);
l.append(3);
l.append(4);
lI = l.constEnd();
while(lI != l.constBegin()) {
std::cout << *lI << std::endl;
--lI;
}
I get this output:
17
4
3
2
I already solved it by using the QListIterator<int>
, but I really don't get why this isn't working!
Thanks in advance ...
Thanks for the help, I didn't know that end() isn't pointing to the last element. Therefore, you only have to decrement before you use the node value.
while(lI != l.constBegin()) {
--lI;
std::cout << *lI << std::endl;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With