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

QVector/QList insists on using Copy Assignment Constructor

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Not Evaluated
    • None
    • 6.2.3
    • None
    • All

    Description

      The attached example compiles and runs fine in Qt5 or in all Qt Version when using std::vector or std::list.

       

      But using Qt6 and QVector/QList the compiler insists on using the Copy Assignment Constructor which, of course, is deleted. Because the class has const members.

      class TestClassConst
      {
      public:
          TestClassConst() = delete;
          TestClassConst(int i, const QString &str) : a(i), string(str) {}
      
      private:
          const int a = 0;
          const QString string;
      };
      
      int main(int argc, char *argv[])
      {
         QGuiApplication app(argc, argv);
          
          QVector<TestClassConst> list;
      //    std::vector<TestClassConst> list;
      //    std::list<TestClassConst>list;
      
          for(int i = 0; i < 10; ++i){
              list.append(TestClassConst{i, QString::number(i)});
          }    
      
         return app.exec();
      }
      

      I would have expected that `emplaceBack(i, QString::number)` would at least work, but that also insists on using the copy assignment operator.

      I don't think this is working as intended.

      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
              jhilk Jonas Hilk
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes