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

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

    XMLWordPrintable

Details

    • 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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              peppe Giuseppe D'Angelo
              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