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. Is it possible to inherit from an Qt Ui Designer Class?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 770 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.
  • I Offline
    I Offline
    incam
    wrote on last edited by incam
    #1

    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.

    dialog.h

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

    BoardDialog.h

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

    BoardDialog.cpp

    #include "boarddialog.h"
    
    BoardDialog::BoardDialog(Project *project) :
        Dialog(project)
    {
        ui->keyboardWidget->hide();    // here I get the error message "member access into incomplete type 'Ui::Dialog' "
    }
    
    jsulmJ 1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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.

      (Z(:^

      I 1 Reply Last reply
      2
      • I incam

        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.

        dialog.h

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

        BoardDialog.h

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

        BoardDialog.cpp

        #include "boarddialog.h"
        
        BoardDialog::BoardDialog(Project *project) :
            Dialog(project)
        {
            ui->keyboardWidget->hide();    // here I get the error message "member access into incomplete type 'Ui::Dialog' "
        }
        
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • I Offline
          I Offline
          incam
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • sierdzioS sierdzio

            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.

            I Offline
            I Offline
            incam
            wrote on last edited by
            #5

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

            Pablo J. RoginaP 1 Reply Last reply
            0
            • I incam

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

              Pablo J. RoginaP Offline
              Pablo J. RoginaP Offline
              Pablo J. Rogina
              wrote on last edited by
              #6

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

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              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