Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT 5.9.6 - getting lot of compiler warnings - implicitly-declared ‘constexpr QVariant::Private& QVariant::Private::operator=(const QVariant::Private&)’ is deprecated [-Wdeprecated-copy]
Forum Updated to NodeBB v4.3 + New Features

QT 5.9.6 - getting lot of compiler warnings - implicitly-declared ‘constexpr QVariant::Private& QVariant::Private::operator=(const QVariant::Private&)’ is deprecated [-Wdeprecated-copy]

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 3.5k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    Rajakumar_QT
    wrote on last edited by
    #1

    Hi

    I am currently using Qt 5.9.6 with GCC compiler , i have created a simple sample app which shows the mainwindow, but getting lot of compiler warnings.

    #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
        return a.exec();
    }
    

    warnings:

    /home/rajakumara/Qt5.9.6/5.9.6/gcc_64/bin/uic ../DEP_TEST/mainwindow.ui -o ui_mainwindow.h
    g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../DEP_TEST -I. -I../Qt5.9.6/5.9.6/gcc_64/include -I../Qt5.9.6/5.9.6/gcc_64/include/QtWidgets -I../Qt5.9.6/5.9.6/gcc_64/include/QtGui -I../Qt5.9.6/5.9.6/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I. -I../Qt5.9.6/5.9.6/gcc_64/mkspecs/linux-g++ -o main.o ../DEP_TEST/main.cpp
    In file included from ../Qt5.9.6/5.9.6/gcc_64/include/QtCore/qlocale.h:43,
    from ../Qt5.9.6/5.9.6/gcc_64/include/QtGui/qguiapplication.h:47,
    from ../Qt5.9.6/5.9.6/gcc_64/include/QtWidgets/qapplication.h:52,
    from ../Qt5.9.6/5.9.6/gcc_64/include/QtWidgets/QApplication:1,
    from ../DEP_TEST/main.cpp:2:
    ../Qt5.9.6/5.9.6/gcc_64/include/QtCore/qvariant.h: In constructor ‘QVariant::QVariant(QVariant&&)’:
    ../Qt5.9.6/5.9.6/gcc_64/include/QtCore/qvariant.h:265:25: warning: implicitly-declared ‘constexpr QVariant::Private& QVariant::Private::operator=(const QVariant::Private&)’ is deprecated [-Wdeprecated-copy]
    265 | { other.d = Private(); }
    | ^
    ../Qt5.9.6/5.9.6/gcc_64/include/QtCore/qvariant.h:380:16: note: because ‘QVariant::Private’ has user-provided ‘QVariant::Private::Private(const QVariant::Private&)’
    380 | inline Private(const Private &other) Q_DECL_NOTHROW
    ^~~~~~~

    Thanks in Advance.

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

      Use a newer Qt version or an older gcc or disable the warning via QMAKE_CXXFLAGS.

      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
      • R Offline
        R Offline
        Rajakumar_QT
        wrote on last edited by
        #3

        i tried gcc version -8 above the warnings are not showing up.but the warning exists in gcc version -9 and version-10.

        If possible can u please share me a link or description which explains why this warnings are shown in when we use lower version of QT with higher version
        GCC.

        Thanks in Advance.

        S Christian EhrlicherC 2 Replies Last reply
        0
        • R Rajakumar_QT

          i tried gcc version -8 above the warnings are not showing up.but the warning exists in gcc version -9 and version-10.

          If possible can u please share me a link or description which explains why this warnings are shown in when we use lower version of QT with higher version
          GCC.

          Thanks in Advance.

          S Offline
          S Offline
          SimonSchroeder
          wrote on last edited by
          #4

          @Rajakumar_QT said in QT 5.9.6 - getting lot of compiler warnings - implicitly-declared ‘constexpr QVariant::Private& QVariant::Private::operator=(const QVariant::Private&)’ is deprecated [-Wdeprecated-copy]:

          If possible can u please share me a link or description which explains why this warnings are shown in when we use lower version of QT with higher version
          GCC.

          Most likely this has to do with the ever changing C++ standard. My guess is that the C++ standard deprecated this behavior. Newer versions of GCC know about this and give a corresponding warning. Older versions of Qt couldn't have been written against future standards. And older versions of Qt are also not updated to conform to newer C++ standards. This is what current versions of Qt are for. Usually, Qt states which compiler versions are supported for which Qt version. You have to match the two to avoid any warnings. Thus: Either use an older compiler or use a more recent version of Qt.

          One other trick is to disable warnings around the corresponding include of the Qt header. Compilers usually have something like a #pragma to turn warnings off and on again and this would be used right before and after the #include of the Qt header in question. Though you should have additional guards (#ifdefs) that apply the #pragma only for GCC (not other compilers) and only specific older versions of Qt (if you decide to later switch to a newer version of Qt somewhere far in the future, you still want the compiler to give as many warnings as possible).

          1 Reply Last reply
          0
          • R Rajakumar_QT

            i tried gcc version -8 above the warnings are not showing up.but the warning exists in gcc version -9 and version-10.

            If possible can u please share me a link or description which explains why this warnings are shown in when we use lower version of QT with higher version
            GCC.

            Thanks in Advance.

            Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Rajakumar_QT said in QT 5.9.6 - getting lot of compiler warnings - implicitly-declared ‘constexpr QVariant::Private& QVariant::Private::operator=(const QVariant::Private&)’ is deprecated [-Wdeprecated-copy]:

            explains why this warnings are shown

            Because the newer compiler added this warning as you see by yourself.
            Simply disable the warning if you don't like it as I wrote above.

            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
            0
            • R Offline
              R Offline
              Rajakumar_QT
              wrote on last edited by
              #6

              thanks for the support

              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