Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QGroupBox derived class does not inherit setParent(QObject* parent);



  • So I have this class:

    class Profile : public QGroupBox
    

    And I see that QGroupBox inherits from QWidget, which inherits from QObject, which has the method:

    void setParent(QObject* parent);
    

    But then I try to access this inherited method in another method of my MainWindow class:

    void MainWindow::add_profile(const Profile* profile)
    {
        profile->setParent(ui->scrollAreaWidgetContents_2);
        //          ^^^    error here: no matching member function for call to 'setParent'
        // stuff
    }
    

    Any suggestions?

    Thx.


  • Lifetime Qt Champion

    setParent() is not a const function so don't pass a const pointer.


Log in to reply