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



  • 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.


  • Moderators

    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:)


  • Moderators

    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.



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.