Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. compiler reports that Ui is an incomplete type
Forum Updated to NodeBB v4.3 + New Features

compiler reports that Ui is an incomplete type

Scheduled Pinned Locked Moved Solved C++ Gurus
16 Posts 5 Posters 5.3k Views 4 Watching
  • 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 Offline
    M Offline
    mzimmers
    wrote on 10 Jun 2019, 14:35 last edited by
    #1

    Class is defined/constructed as follows:

    namespace Ui {
        class WifiSetup;
    }
    class WifiSetup : public QDialog
    {
        Q_OBJECT
    private:
        Ui::WifiSetup *ui;
    ...
    
    WifiSetup::WifiSetup(QString serialNbr, DeviceModel *d, QModelIndex *qmi, Worker *pWorker, QWidget *parent) :
        QDialog(parent),
        ui(new Ui::WifiSetup),
    

    and I'm getting the error message:

    error: allocation of incomplete type 'Ui::WifiSetup'
    

    What did I do wrong? Thanks...

    A 1 Reply Last reply 10 Jun 2019, 15:08
    0
    • F Offline
      F Offline
      fcarney
      wrote on 10 Jun 2019, 15:08 last edited by
      #2

      @mzimmers said in compiler reports that Ui is an incomplete type:

      namespace Ui {
      class WifiSetup;
      }

      Is this intended to be fleshed out later? class WifiSetup; is a class prototype. Is it defined somewhere else?
      If you want this to define a class you can do this I think:

      class WifiSetup {
      };
      

      C++ is a perfectly valid school of magic.

      A 1 Reply Last reply 10 Jun 2019, 15:11
      1
      • M mzimmers
        10 Jun 2019, 14:35

        Class is defined/constructed as follows:

        namespace Ui {
            class WifiSetup;
        }
        class WifiSetup : public QDialog
        {
            Q_OBJECT
        private:
            Ui::WifiSetup *ui;
        ...
        
        WifiSetup::WifiSetup(QString serialNbr, DeviceModel *d, QModelIndex *qmi, Worker *pWorker, QWidget *parent) :
            QDialog(parent),
            ui(new Ui::WifiSetup),
        

        and I'm getting the error message:

        error: allocation of incomplete type 'Ui::WifiSetup'
        

        What did I do wrong? Thanks...

        A Offline
        A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on 10 Jun 2019, 15:08 last edited by
        #3

        @mzimmers so far you only have a forward declaration of that type.

        To use it, you need to give the full class declaration first, so the compiler knows the members of your class.

        Regards

        Qt has to stay free or it will die.

        1 Reply Last reply
        2
        • F fcarney
          10 Jun 2019, 15:08

          @mzimmers said in compiler reports that Ui is an incomplete type:

          namespace Ui {
          class WifiSetup;
          }

          Is this intended to be fleshed out later? class WifiSetup; is a class prototype. Is it defined somewhere else?
          If you want this to define a class you can do this I think:

          class WifiSetup {
          };
          
          A Offline
          A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on 10 Jun 2019, 15:11 last edited by
          #4

          @fcarney Ui::WifiSetup, that is.

          But most likely an auto-generated designer widget. If so, then including the ui_wifisetup.h should suffice.

          Qt has to stay free or it will die.

          M 1 Reply Last reply 10 Jun 2019, 15:30
          1
          • A aha_1980
            10 Jun 2019, 15:11

            @fcarney Ui::WifiSetup, that is.

            But most likely an auto-generated designer widget. If so, then including the ui_wifisetup.h should suffice.

            M Offline
            M Offline
            mzimmers
            wrote on 10 Jun 2019, 15:30 last edited by
            #5

            @aha_1980 I don't understand -- my class definition is in the header file, and the header file is included in the source file. (I didn't bother including this in my original post, as I thought it was the implicit method of creating classes.)

            wifisetup.h:

            namespace Ui {
                class WifiSetup;
            }
            
            class WifiSetup : public QDialog
            {
                Q_OBJECT
            
            private:
                Ui::WifiSetup *ui;
            ...
            

            wifisetup.cpp:

            #include "wifisetup.h"
            #include "ui_wifisetup.h"
            #include "worker.h"
            
            WifiSetup::WifiSetup(QString serialNbr, DeviceModel *d, QModelIndex *qmi, Worker *pWorker, QWidget *parent) :
                QDialog(parent),
                ui(new Ui::WifiSetup),
            ...
            

            I'd expect the definition (from the header file) to be visible here, so I guess I don't understand how this really works.

            A F 2 Replies Last reply 10 Jun 2019, 15:56
            0
            • M mzimmers
              10 Jun 2019, 15:30

              @aha_1980 I don't understand -- my class definition is in the header file, and the header file is included in the source file. (I didn't bother including this in my original post, as I thought it was the implicit method of creating classes.)

              wifisetup.h:

              namespace Ui {
                  class WifiSetup;
              }
              
              class WifiSetup : public QDialog
              {
                  Q_OBJECT
              
              private:
                  Ui::WifiSetup *ui;
              ...
              

              wifisetup.cpp:

              #include "wifisetup.h"
              #include "ui_wifisetup.h"
              #include "worker.h"
              
              WifiSetup::WifiSetup(QString serialNbr, DeviceModel *d, QModelIndex *qmi, Worker *pWorker, QWidget *parent) :
                  QDialog(parent),
                  ui(new Ui::WifiSetup),
              ...
              

              I'd expect the definition (from the header file) to be visible here, so I guess I don't understand how this really works.

              A Offline
              A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on 10 Jun 2019, 15:56 last edited by
              #6

              @mzimmers you have a class WifiSetup, but no class Ui::WifiSetup. Thats what the compiler complains about.

              Qt has to stay free or it will die.

              M 1 Reply Last reply 10 Jun 2019, 15:59
              0
              • A aha_1980
                10 Jun 2019, 15:56

                @mzimmers you have a class WifiSetup, but no class Ui::WifiSetup. Thats what the compiler complains about.

                M Offline
                M Offline
                mzimmers
                wrote on 10 Jun 2019, 15:59 last edited by
                #7

                @aha_1980 I'm doing (what appears to be) the same thing in another class, and that compiles fine.

                namespace Ui
                {
                    class EditDialog;
                }
                
                class EditDialog : public QDialog
                {
                    Q_OBJECT
                public:
                    explicit EditDialog(DeviceModel *d, QModelIndex *qmi, Worker *pWorker, QWidget *parent = nullptr);
                private:
                    Ui::EditDialog *ui;
                ...
                }
                EditDialog::EditDialog(DeviceModel *d, QModelIndex *qmi, Worker *pWorker, QWidget *parent) :
                    QDialog(parent),
                    ui(new Ui::EditDialog),
                ...
                

                I'm sure I'm overlooking something obvious, but they look the same to me.

                1 Reply Last reply
                0
                • M mzimmers
                  10 Jun 2019, 15:30

                  @aha_1980 I don't understand -- my class definition is in the header file, and the header file is included in the source file. (I didn't bother including this in my original post, as I thought it was the implicit method of creating classes.)

                  wifisetup.h:

                  namespace Ui {
                      class WifiSetup;
                  }
                  
                  class WifiSetup : public QDialog
                  {
                      Q_OBJECT
                  
                  private:
                      Ui::WifiSetup *ui;
                  ...
                  

                  wifisetup.cpp:

                  #include "wifisetup.h"
                  #include "ui_wifisetup.h"
                  #include "worker.h"
                  
                  WifiSetup::WifiSetup(QString serialNbr, DeviceModel *d, QModelIndex *qmi, Worker *pWorker, QWidget *parent) :
                      QDialog(parent),
                      ui(new Ui::WifiSetup),
                  ...
                  

                  I'd expect the definition (from the header file) to be visible here, so I guess I don't understand how this really works.

                  F Offline
                  F Offline
                  fcarney
                  wrote on 10 Jun 2019, 16:17 last edited by
                  #8

                  @mzimmers said in compiler reports that Ui is an incomplete type:

                  new Ui::WifiSetup

                  Is this a new class? I would do a clean project, a run qmake, and the build for good measure. You are right, they do look the same. It should work.

                  C++ is a perfectly valid school of magic.

                  M 1 Reply Last reply 10 Jun 2019, 16:20
                  0
                  • F fcarney
                    10 Jun 2019, 16:17

                    @mzimmers said in compiler reports that Ui is an incomplete type:

                    new Ui::WifiSetup

                    Is this a new class? I would do a clean project, a run qmake, and the build for good measure. You are right, they do look the same. It should work.

                    M Offline
                    M Offline
                    mzimmers
                    wrote on 10 Jun 2019, 16:20 last edited by
                    #9

                    @fcarney I've done all that. Even deleted my build directory. I know it's some brain-dead mistake I've introduced somewhere, but I sure can't find it.

                    kshegunovK 1 Reply Last reply 10 Jun 2019, 16:54
                    0
                    • M mzimmers
                      10 Jun 2019, 16:20

                      @fcarney I've done all that. Even deleted my build directory. I know it's some brain-dead mistake I've introduced somewhere, but I sure can't find it.

                      kshegunovK Offline
                      kshegunovK Offline
                      kshegunov
                      Moderators
                      wrote on 10 Jun 2019, 16:54 last edited by
                      #10

                      @mzimmers said in compiler reports that Ui is an incomplete type:

                      I know it's some brain-dead mistake I've introduced somewhere, but I sure can't find it.

                      @aha_1980 said it. You have, I'm betting, something called wifisetup.ui in your project. If you don't then that's a problem. Then you should have #include "ui_wifisetup.h" in your cpp file. If you don't then that's a problem. Note that Ui::WifiSetup is different from WifiSetup, the former's namespaced for good reason.

                      Read and abide by the Qt Code of Conduct

                      M 1 Reply Last reply 10 Jun 2019, 17:13
                      1
                      • kshegunovK kshegunov
                        10 Jun 2019, 16:54

                        @mzimmers said in compiler reports that Ui is an incomplete type:

                        I know it's some brain-dead mistake I've introduced somewhere, but I sure can't find it.

                        @aha_1980 said it. You have, I'm betting, something called wifisetup.ui in your project. If you don't then that's a problem. Then you should have #include "ui_wifisetup.h" in your cpp file. If you don't then that's a problem. Note that Ui::WifiSetup is different from WifiSetup, the former's namespaced for good reason.

                        M Offline
                        M Offline
                        mzimmers
                        wrote on 10 Jun 2019, 17:13 last edited by
                        #11

                        @kshegunov yes on both counts: I have a wifisetup.ui file in the project, and I include "ui_wifisetup.h" in my wifisetup.cpp file. It should be functionally identical to my editdialog class, which compiles just fine. Wifisetup used to compile, too. But I introduced a change somewhere that I can't find and it's causing this issue.

                        kshegunovK 1 Reply Last reply 10 Jun 2019, 18:30
                        0
                        • M mzimmers
                          10 Jun 2019, 17:13

                          @kshegunov yes on both counts: I have a wifisetup.ui file in the project, and I include "ui_wifisetup.h" in my wifisetup.cpp file. It should be functionally identical to my editdialog class, which compiles just fine. Wifisetup used to compile, too. But I introduced a change somewhere that I can't find and it's causing this issue.

                          kshegunovK Offline
                          kshegunovK Offline
                          kshegunov
                          Moderators
                          wrote on 10 Jun 2019, 18:30 last edited by kshegunov 6 Oct 2019, 18:31
                          #12
                          error: allocation of incomplete type 'Ui::WifiSetup'
                          

                          This means the class declaration is not available. Troubleshoot as follows (skip steps that you've checked already):

                          1. Make sure you include the generated header where you allocate.
                          2. Make sure qmake's rerun
                          3. Make sure the name of the widget in the designer matches the name of the class.

                          Read and abide by the Qt Code of Conduct

                          M 1 Reply Last reply 10 Jun 2019, 19:40
                          5
                          • F Offline
                            F Offline
                            fcarney
                            wrote on 10 Jun 2019, 18:40 last edited by
                            #13

                            @mzimmers said in compiler reports that Ui is an incomplete type:

                            I introduced a change somewhere

                            I think that in order for this to be an issue then that change would have been somewhere in the .h file. Is there anything in the .h that defines the prototype that does anything more than define a pointer than this: Ui::EditDialog *ui; I am thinking of functions defined as inline vs functions defined in a cpp file.

                            or

                            Something is interfering with the compilation of cpp files associated with that object. Did a cpp file get excluded from the pro file? By accident or design?

                            C++ is a perfectly valid school of magic.

                            kshegunovK 1 Reply Last reply 10 Jun 2019, 18:41
                            0
                            • F fcarney
                              10 Jun 2019, 18:40

                              @mzimmers said in compiler reports that Ui is an incomplete type:

                              I introduced a change somewhere

                              I think that in order for this to be an issue then that change would have been somewhere in the .h file. Is there anything in the .h that defines the prototype that does anything more than define a pointer than this: Ui::EditDialog *ui; I am thinking of functions defined as inline vs functions defined in a cpp file.

                              or

                              Something is interfering with the compilation of cpp files associated with that object. Did a cpp file get excluded from the pro file? By accident or design?

                              kshegunovK Offline
                              kshegunovK Offline
                              kshegunov
                              Moderators
                              wrote on 10 Jun 2019, 18:41 last edited by
                              #14

                              You're wrong. :)

                              Read and abide by the Qt Code of Conduct

                              1 Reply Last reply
                              0
                              • kshegunovK kshegunov
                                10 Jun 2019, 18:30
                                error: allocation of incomplete type 'Ui::WifiSetup'
                                

                                This means the class declaration is not available. Troubleshoot as follows (skip steps that you've checked already):

                                1. Make sure you include the generated header where you allocate.
                                2. Make sure qmake's rerun
                                3. Make sure the name of the widget in the designer matches the name of the class.
                                M Offline
                                M Offline
                                mzimmers
                                wrote on 10 Jun 2019, 19:40 last edited by
                                #15

                                @kshegunov said in compiler reports that Ui is an incomplete type:

                                error: allocation of incomplete type 'Ui::WifiSetup'
                                

                                This means the class declaration is not available. Troubleshoot as follows (skip steps that you've checked already):

                                1. Make sure you include the generated header where you allocate.
                                2. Make sure qmake's rerun
                                3. Make sure the name of the widget in the designer matches the name of the class.

                                Ding. It was #3, a result of my hasty editing in Designer. Thanks to all who looked at this.

                                1 Reply Last reply
                                4
                                • Kent-DorfmanK Offline
                                  Kent-DorfmanK Offline
                                  Kent-Dorfman
                                  wrote on 11 Jun 2019, 04:23 last edited by
                                  #16
                                  This post is deleted!
                                  1 Reply Last reply
                                  0

                                  1/16

                                  10 Jun 2019, 14:35

                                  • Login

                                  • Login or register to search.
                                  1 out of 16
                                  • First post
                                    1/16
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved