Hello community!

I have following situation:

Qt Code:
  1. typedef QMapIterator<double, QCPFinancialData> QCPFinancialDataMapIterator;
  2.  
  3. class QCP_LIB_DECL QCPFinancialData
  4. {
  5. public:
  6. QCPFinancialData();
  7. QCPFinancialData(double key, double open, double high, double low, double close);
  8. double key, open, high, low, close;
  9. friend QDebug operator<<(QDebug dbg, QCPFinancialData& data); // AW
  10. };
To copy to clipboard, switch view to plain text mode 

Here the code snippet:

Qt Code:
  1. QCPFinancialDataMap map;
  2. QCPFinancialDataMapIterator it( map );
  3. // initialize map ...
  4. // map after initialization:
  5. map = QCPFinancialDataMap(QMap(0,QCPFinancialData(0,10,15,8,12) ) QMap(900,QCPFinancialData(900,11,16,7,13) ) QMap(1800,QCPFinancialData(1800,12,17,6,14) ) QMap(2700,QCPFinancialData(2700,13,18,5,15) ) )
  6. . . .
To copy to clipboard, switch view to plain text mode 
// I make 3 calls to it.next(), all behaving as expected.
Then I have to go one step backwards, so I call it.previous(), but without any effect! I have to make a second call to it.previous() to get the desired result! Same behavior moving the iterator forward to reach the original position! - see code snippet and printout -

Qt Code:
  1. qDebug() << "1: it.value().close =" << it.value().close; // OK, is 14
  2. it.previous(); // no effect!
  3. qDebug() << "2: it.value().close =" << it.value().close; // should be 13!
  4. it.previous(); // works as expected. Why is a double call of previous() necessary?
  5. qDebug() << "3: it.value().close =" << it.value().close; // OK, is 13
  6. currentBinData.close = it.value().close;
  7. it.next(); // no effect!
  8. qDebug() << "4: it.value().close =" << it.value().close; // should be 14!
  9. it.next(); // works as expected. Why is a double call of next() necessary?
  10. qDebug() << "5: it.value().close =" << it.value().close; // OK, is 14
To copy to clipboard, switch view to plain text mode 

print out:
1: it.value().close = 14
2: it.value().close = 14
3: it.value().close = 13
4: it.value().close = 13
5: it.value().close = 14

The code is doing what I want, but it is not clean.
Any idea?

Thank you for your time.
Alain