Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-95334

QMap<QString,QString>::const_iterator cannot do "it+1" any more

XMLWordPrintable

    • cc584c59de644195ae0c4f7f99ad428e189df07d (qt/qtbase/dev) 62b4c9169c23f510747a384fe3f1ed78bee4b435 (qt/qtbase/6.2)

      I have the following piece of code which worked well in Qt 5:

                  QMap<QString,QString>::const_iterator i;
                  for (i=ride->tags().constBegin(); i != ride->tags().constEnd(); i++) {
      
                          out << "\t\t\t\"" << i.key() << "\": \"" << protect(i.value()) << "\"";
                          if (i+1 != ride->tags().constEnd()) out << ",\n";
                          else out << "\n";
                  }
      

      In Qt6, "i+1" is not possible any more. I get the error message:

      FileIO/Snippets.cpp:149:26: error: no match for ‘operator+’ (operand types are ‘QMap<QString, QString>::const_iterator’ and ‘int’)
        149 |                     if (i+1 != ride->tags().constEnd()) out << ",\n";
      

      And I cannot find anything related in the porting guides
      https://doc.qt.io/qt-6/portingguide.html
      or
      https://doc.qt.io/qt-6/qtcore-changes-qt6.html

      Please bring back the "i+1" capability or provide guidance in the porting docs.

        For Gerrit Dashboard: QTBUG-95334
        # Subject Branch Project Status CR V

            peppe Giuseppe D'Angelo
            andreasbuhr Andreas Buhr
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes