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. warning: implicitly-declared ‘constexpr QJsonValueRef::QJsonValueRef(const QJsonValueRef&)’ is deprecated
QtWS25 Last Chance

warning: implicitly-declared ‘constexpr QJsonValueRef::QJsonValueRef(const QJsonValueRef&)’ is deprecated

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.8k 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.
  • Gilbert LeeG Offline
    Gilbert LeeG Offline
    Gilbert Lee
    wrote on last edited by
    #1

    The following code generates the a warning message.

    #include <QJsonObject>
    
    QJsonValueRef operator << (QJsonValueRef ref, int) {
    	return ref;
    }
    
    int main() {
    	QJsonObject jo;
    	jo["foo"] << 1;
    }
    
    warning: implicitly-declared ‘constexpr QJsonValueRef::QJsonValueRef(const QJsonValueRef&)’ is deprecated
    

    $ qmake --version
    QMake version 3.1
    Using Qt version 5.14.2 in /opt/Qt/5.14.2/gcc_64/lib

    Thank you in advance.

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

      Don't copy the QJsonValue, pass it by reference. Also I don't understand what the operator in your example should do at all.

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

      Gilbert LeeG 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        Don't copy the QJsonValue, pass it by reference. Also I don't understand what the operator in your example should do at all.

        Gilbert LeeG Offline
        Gilbert LeeG Offline
        Gilbert Lee
        wrote on last edited by Gilbert Lee
        #3

        @Christian-Ehrlicher

        It's a code which just shows a warning message that copy constructor does not exist in QJsonValueRef class, and QJsonValueRef is a reference class of QJsonValue.

        Gilbert LeeG 1 Reply Last reply
        0
        • Gilbert LeeG Gilbert Lee

          @Christian-Ehrlicher

          It's a code which just shows a warning message that copy constructor does not exist in QJsonValueRef class, and QJsonValueRef is a reference class of QJsonValue.

          Gilbert LeeG Offline
          Gilbert LeeG Offline
          Gilbert Lee
          wrote on last edited by
          #4

          FYI,
          https://en.cppreference.com/w/cpp/language/rule_of_three

          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