Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    QTabWidget::QTabWidget(const QTabWidget&)' is private

    General and Desktop
    3
    4
    940
    Loading More Posts
    • 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.
    • M
      mehdi.nine last edited by

      I develop a program and have 10 backup from it. i add some line to it and when i compile project it have following error:
      @
      C:\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtWidgets\qtabwidget.h:173: error: 'QTabWidget::QTabWidget(const QTabWidget&)' is private
      @
      the error is from * line
      @
      namespace Ui {
      class ContentControl;
      }

      class ContentControl:public QTabWidget //* from this line///////////////////////////////
      {
      Q_OBJECT

      public:
      .
      .
      .
      }
      @
      all backups has this error now. any idea? i re install QT but problem has exist.

      1 Reply Last reply Reply Quote 0
      • T
        tobias.hunger last edited by

        The error is correct, you can not copy QObjects (and all QWidgets are QObjects).

        My guess is that you have a copy constructor defined for ContentControl.

        Try reinstalling Qt a couple more times and then fix your code when you are tired of doing that:)

        1 Reply Last reply Reply Quote 0
        • Chris Kawa
          Chris Kawa Moderators last edited by

          The copy constructor is generated automatically if you don't prevent it manually (by declaring it private or via c++11 delete).

          These are few (horrible) examples that could generate this error:
          @
          ContentControl c1;
          ContentControl c2 = c1; // error

          void someFunction(ContentControl) {...}
          someFunction(c1); //error

          ContentControl someFunc2() { return ContentControl; }
          someFunc2(); //error
          @
          In short don't try to pass QObjects by value.

          1 Reply Last reply Reply Quote 0
          • M
            mehdi.nine last edited by

            thanks for you reply the problem has solved when i delete ContentControl that send to another class.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post