Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Definition of implicit copy constructor for 'QListSpecialMethodsBase<QString>' is deprecated because it has a user-declared destructor

Definition of implicit copy constructor for 'QListSpecialMethodsBase<QString>' is deprecated because it has a user-declared destructor

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
6 Posts 3 Posters 340 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • surfciusS Offline
    surfciusS Offline
    surfcius
    wrote on last edited by
    #1

    Qt's official website tells users write code like this:
    1.png
    However, in QtCreator, the compilation environment warns:
    2.png
    How to remove this warning? It is better to modify the code rather than block this warning.
    Thanks!

    JonBJ 1 Reply Last reply
    0
    • surfciusS surfcius

      Qt's official website tells users write code like this:
      1.png
      However, in QtCreator, the compilation environment warns:
      2.png
      How to remove this warning? It is better to modify the code rather than block this warning.
      Thanks!

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @surfcius
      Please don't post code screenshots, and not even give the link reference for it. I cannot copy from what you post to test, I have to type it all in by hand :( Post copied code.

      Ubuntu 24.04, Qt 6.4.2, gcc 13.2

      #include <QCoreApplication>
      
      QStringList function()
      {
          QStringList types;
          types << "...";
          return types;
      }
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
          
          QStringList list = function();
          return a.exec();
      }
      

      gives me no such warning, compiles and works. Does yours only give that warning from the code completion model inside Creator or do you get that warning when you actually compile?

      1 Reply Last reply
      2
      • surfciusS Offline
        surfciusS Offline
        surfcius
        wrote on last edited by
        #3

        Thank you for your answer! That warning comes from the code completion model inside Creator.

        1 Reply Last reply
        0
        • surfciusS Offline
          surfciusS Offline
          surfcius
          wrote on last edited by
          #4

          In Qt, classes inherited from QList all have the same problem. For example, QModelIndexList. As shown in the following code. The reason is that QList defines the destructor, but does not define the copy constructor and copy assignment function, and clang will give a warning. It is not appropriate for users to modify the QList code themselves.

          #include <QCoreApplication>
          #include <QModelIndexList>
          
          QModelIndexList function()
          {
              QModelIndexList indexes;
          
              return indexes;
          }
          
          int main(int argc, char *argv[])
          {
              QCoreApplication a(argc, argv);
          
              QModelIndexList indexes = function();
          
              return a.exec();
          }
          
          

          The code is listed above, and the environment screenshots are also given below:
          3.png

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Simply deactive this warning - it's a false positive.
            The classes have a copy ctor as you can see in the documentation: https://doc.qt.io/qt-6/qlist.html#QList-2

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            1
            • Christian EhrlicherC Christian Ehrlicher moved this topic from General and Desktop on
            • JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @surfcius , @Christian-Ehrlicher
              In my code as pasted, Creator 13 I think (unless it's 11?), clang code completer too, I do not get that warning in the IDE. I don't believe I have touched any clang settings, I suspect my C++ is C++17. Why do I not get it?

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved