Important: Please read the Qt Code of Conduct -

Is it possible to inherit from an Qt Ui Designer Class?

  • Hey everyone,

    I asked myself and could not find an answer about how it is possible to inherit Ui Designer Classes.
    I got the Dialog class for which I designed an Ui and the BoardDialog class, which should inherit Dialog.

    Qt Creator always tells me "member access into incomplete type 'Ui::Dialog' if I try to access the ui in the subclass.
    Normally this was caused by forgetting to include the .h-file, but now it is not the problem.

    I hope you can help,
    Thank you.


    #include <QDialog>
    #include <QGraphicsScene>
    #include <project.h>
    namespace Ui {
        class Dialog;
    class Dialog : public QDialog
        Ui::Dialog *ui;
        Project *m_project;
        QGraphicsScene *m_prevScene;
        explicit Dialog(Project *project);
        virtual ~Dialog();
        virtual void save();
        void cancel();
        virtual void updatePreview();


    #include <board.h>
    #include <dialog.h>
    namespace Ui {
        class BoardDialog;
    class BoardDialog : public Dialog
        Board *m_board;
        BoardDialog(Project *project);


    #include "boarddialog.h"
    BoardDialog::BoardDialog(Project *project) :
        ui->keyboardWidget->hide();    // here I get the error message "member access into incomplete type 'Ui::Dialog' "

  • Moderators

    Make sure you run qmake and make at least once. Then the ui_boarddialog.h will be generated and Qt Creator should pick it up.

  • Lifetime Qt Champion

    This post is deleted!

  • This post is deleted!

  • @sierdzio
    Thank you, including ui_dialog.h worked for me.

  • @incam if your issue is solved, please don't forget to mark your post as such. Thanks.

Log in to reply