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

Details

    Description

      #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.

      Attachments

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes