I have created a simple map and an iterator on it. When i move the iterator to next items, it performs well. After forwarding the iterator, if I ask it to go back for previous item and get value() of the iterator, it is not really the previous item value and actually the value is not changed at all. It seems there is something wrong or maybe I'm using it in a wrong way! Where is the problem?
see the below code
#include "mainwindow.h"
#include <QApplication>
#include <QMap>
#include <qiterator.h>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMap<double,int> map;
map.insert(4234,3);
map.insert(4200,2);
map.insert(4100,1);
map.insert(4000,0);
QMapIterator<double, int> i(map);
i.toFront();
i.next();
i.next();
int va1 = i.value(); // val1 is 1 as expected
i.previous();
int val2 = i.value(); // It is expected that val2 should be 0 but is still Surprisingly 1!!!!
return a.exec();
}