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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 6.2.0 Beta1
    • Fix Version/s: 6.2.0 Beta2, 6.3.0 Alpha
    • Component/s: Documentation
    • Labels:
      None
    • Commits:
      cc584c59de644195ae0c4f7f99ad428e189df07d (qt/qtbase/dev) 62b4c9169c23f510747a384fe3f1ed78bee4b435 (qt/qtbase/6.2)

      Description

      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.

        Attachments

          Issue Links

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

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes