Is it possible to loop a QHash by the insert order? The method below seem to loop the hash by some other factor:
QHashIterator<QString, QString> i(hash);
while (i.hasNext()) {
i.next();
qDebug() << i.key() << ": " << i.value();
}
EDIT:
I figured it was impossible with QHash but what should I use instead?
From QHash documentation,
So it is not possible.
If you want ordering based on the keys, use
QMapinstead..Hope it helps..
Edit:
If you don’t need
KeyandValueLogical mapping and just their values, you can useFor e.g:
The first value can be obtained by
Similarly for the second value in the QPair,
And you can iterate over the
QListto retrieve the elements in the inserted order..