Great! Qt container supports foreach iteration, which simplies largely the code. See the example for comparison:
========= java-like iterator===============
QLinkedList<> list;
...
QLinkedListIterator<> i(list);
while (i.hasNext())
qDebug()<< i.next()
========== STL-like iterator=============
QLinkedList<> list;
...
QListedList<>::const_iterator it = list.begin();
while( it!= list.end())
{
qDebug()<< (*it); ++it; }
=========foreach iteration===============
QLinkedList<>> list;
...
foreach (QString str, list)
qDebug() << str
===================================
Reference:
The Foreach loop may be deprecated quite soon: https://www.kdab.com/goodbye-q_foreach/
ReplyDelete