I am compiling below code in QT version 4.8 as well as in 5.12.9 .
QHash<QString, int> m_userDataHash;
m_userDataHash.insert("white", 1);
m_userDataHash.insert("yellow", 3);
m_userDataHash.insert("lightblue", 5);
m_userDataHash.insert("darkblue", 7);
m_userDataHash.insert("pink", 9);
m_userDataHash.insert("red", 11);
m_userDataHash.insert("green", 13);
m_userDataHash.insert("black", 15);
m_userDataHash.insert("grey", 17);
QHashIterator<QString, int> i(m_userDataHash);
while (i.hasNext())
{
i.next();
ui->ColorCombo->addItem(i.key());
}
This code is behaving differently as the order of insertion is different in different qt version.
In Qt 5.12.9
In Qt 4.8
How can I solve this problem? Why is this happening?
I checked the QHash documentation but could not figure out anything. https://doc.qt.io/qt-5/qhash.html#insert