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

[REG 5.15 -> 6.0]: QVector can no longer insert classes that contain const non-POD members

XMLWordPrintable

      #include <vector>
      #include <QVector>
      
      struct MyData
      {
          MyData(const QString& str) : str(str) {}
          const QString str;
      };
      
      int main()
      {
          std::vector<MyData> sVec{MyData("A"), MyData{"B"}}; // OK
          sVec.push_back(MyData("C"));                        // OK
          sVec.emplace_back("D");                             // OK
      
          QVector<MyData> qVec{MyData("A"), MyData{"B"}}; // OK
          qVec.push_back(MyData("C"));                    // OK in Qt 5. Fails to compile in Qt 6
          qVec.emplace_back("D");                         // N/A in Qt 5. Fails to compile in Qt 6
      }
      

      If this is expected QVector behaviour, could you please advise on how affected users should port from Qt 5 -> Qt 6? Thanks.

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

            thiago Thiago Macieira
            skoh-qt Sze Howe Koh
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes