Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. setupUi is not a member of my QT application
Qt 6.11 is out! See what's new in the release blog

setupUi is not a member of my QT application

Scheduled Pinned Locked Moved Unsolved General and Desktop
41 Posts 3 Posters 14.8k Views 2 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.
  • L Offline
    L Offline
    lfreeman6490
    wrote on last edited by
    #5

    With that I get that there is no appropriate default constructor available

    JoeCFDJ 1 Reply Last reply
    0
    • L lfreeman6490

      With that I get that there is no appropriate default constructor available

      JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #6

      @lfreeman6490 always make destructor ~Pathloss(); virtual
      virtual ~Pathloss();
      What is the error message?

      1 Reply Last reply
      1
      • L Offline
        L Offline
        lfreeman6490
        wrote on last edited by lfreeman6490
        #7

        The specific error messages are

        C2512: 'Ui::Pathloss' no appropriate default constructor available
        
        C1903: unable to recover from previous error(s); stopping compilation
        

        thanks for your help so far, i appreciate it

        1 Reply Last reply
        0
        • JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #8

          I can not see your ui file

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lfreeman6490
            wrote on last edited by
            #9

            I have a 'ui_Pathloss.h' file that is about 800 lines so I can't really post that one. My 'pathloss.ui' file is my design and GUI that I created

            1 Reply Last reply
            0
            • JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on last edited by JoeCFD
              #10

              @JoeCFD said in setupUi is not a member of my QT application:

              Ui::Pathloss

              this constructor Ui::Pathloss() does not exist or defined in private section

              You need something like the following code in the header:
              QT_BEGIN_NAMESPACE

              class Ui_FileDeleteProgressDialog
              {
              public:
              Ui_FileDeleteProgressDialog(){}

              void setupUi( QDialog * dialog )
               {    
               } // setupUi
              

              };

              namespace Ui {
              class FileDeleteProgressDialog: public Ui_FileDeleteProgressDialog {};
              } // namespace Ui

              QT_END_NAMESPACE

              1 Reply Last reply
              0
              • L Offline
                L Offline
                lfreeman6490
                wrote on last edited by
                #11

                Where in my code should I add that? Would that go in my header file?

                JoeCFDJ 1 Reply Last reply
                0
                • L lfreeman6490

                  I am trying to build my QT application, it is throwing an error in my Pathloss.cpp file

                  #include "pathloss.h"
                  #include "ui_pathloss.h"
                  
                  Pathloss::Pathloss(QWidget *parent) :
                      QWidget(parent),
                      ui(new Pathloss)
                  {
                      ui->setupUi(this);
                  }
                  
                  Pathloss::~Pathloss()
                  {
                      delete ui;
                  }
                  
                  

                  and then directs me "see declaration of 'Pathloss'" in my pathloss.h file

                  namespace Ui {
                  class Pathloss;
                  }
                  
                  class Pathloss : public QWidget
                  {
                      Q_OBJECT
                      
                  public:
                      explicit Pathloss(QWidget *parent = 0);
                      ~Pathloss();
                  
                  private:
                      Pathloss *ui;
                  };
                  

                  The exact error message is

                  C2309: 'setupUi': is not a member of 'Pathloss'
                  
                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #12

                  Hi,

                  @lfreeman6490 said in setupUi is not a member of my QT application:

                  ui(new Pathloss)

                  It should be:

                  ui(new Ui::Pathloss)
                  

                  You are missing the namespace for that class.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  L 1 Reply Last reply
                  1
                  • SGaistS SGaist

                    Hi,

                    @lfreeman6490 said in setupUi is not a member of my QT application:

                    ui(new Pathloss)

                    It should be:

                    ui(new Ui::Pathloss)
                    

                    You are missing the namespace for that class.

                    L Offline
                    L Offline
                    lfreeman6490
                    wrote on last edited by
                    #13

                    @SGaist Doing that tells me that there is no appropriate default constructor. Do I have to change all instances of 'Pathloss' to 'Ui::Pathloss'?

                    1 Reply Last reply
                    0
                    • L lfreeman6490

                      Where in my code should I add that? Would that go in my header file?

                      JoeCFDJ Offline
                      JoeCFDJ Offline
                      JoeCFD
                      wrote on last edited by JoeCFD
                      #14

                      @lfreeman6490 They are defined in ui_pathloss.h. Open it and check if the class name is Ui_Pathloss. It is possible that the class name is Ui_pathloss?

                      L 1 Reply Last reply
                      1
                      • JoeCFDJ JoeCFD

                        @lfreeman6490 They are defined in ui_pathloss.h. Open it and check if the class name is Ui_Pathloss. It is possible that the class name is Ui_pathloss?

                        L Offline
                        L Offline
                        lfreeman6490
                        wrote on last edited by
                        #15

                        @JoeCFD the class is named 'Ui_f_pathloss'. This was automated by QT so I didn't change it

                        JoeCFDJ 1 Reply Last reply
                        0
                        • L lfreeman6490

                          @JoeCFD the class is named 'Ui_f_pathloss'. This was automated by QT so I didn't change it

                          JoeCFDJ Offline
                          JoeCFDJ Offline
                          JoeCFD
                          wrote on last edited by JoeCFD
                          #16

                          @lfreeman6490 That is a typical Qt error. You define it in Qt Designer with the matching class name.
                          Load your Qt ui file back to Qt Designer and set class name properly.

                          L 1 Reply Last reply
                          1
                          • JoeCFDJ JoeCFD

                            @lfreeman6490 That is a typical Qt error. You define it in Qt Designer with the matching class name.
                            Load your Qt ui file back to Qt Designer and set class name properly.

                            L Offline
                            L Offline
                            lfreeman6490
                            wrote on last edited by
                            #17

                            @JoeCFD So I should change that to Ui_Pathloss?

                            to look like this?

                            namespace Ui {
                                class Ui_Pathloss: public Ui_Pathloss {};
                                class FileDeleteProgressDialog: public Ui_FileDeleteProgressDialog {};
                            } // namespace Ui
                            
                            JoeCFDJ 1 Reply Last reply
                            0
                            • L lfreeman6490

                              @JoeCFD So I should change that to Ui_Pathloss?

                              to look like this?

                              namespace Ui {
                                  class Ui_Pathloss: public Ui_Pathloss {};
                                  class FileDeleteProgressDialog: public Ui_FileDeleteProgressDialog {};
                              } // namespace Ui
                              
                              JoeCFDJ Offline
                              JoeCFDJ Offline
                              JoeCFD
                              wrote on last edited by JoeCFD
                              #18

                              @lfreeman6490 You do not do this. Load your Qt ui file back to Qt Designer and set class name properly.
                              your class name is f_pathloss in the ui file. This is even not a good name.

                              L JoeCFDJ 2 Replies Last reply
                              1
                              • JoeCFDJ JoeCFD

                                @lfreeman6490 You do not do this. Load your Qt ui file back to Qt Designer and set class name properly.
                                your class name is f_pathloss in the ui file. This is even not a good name.

                                L Offline
                                L Offline
                                lfreeman6490
                                wrote on last edited by
                                #19

                                @JoeCFD I did that and nothing changed, still getting the same error

                                JoeCFDJ 1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #20

                                  Fix what you have in your pathloss.h file to match what you have in your ui_pathloss.h file.

                                  But it sure does look strange that there's such a name mismatch.

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  L 1 Reply Last reply
                                  1
                                  • SGaistS SGaist

                                    Fix what you have in your pathloss.h file to match what you have in your ui_pathloss.h file.

                                    But it sure does look strange that there's such a name mismatch.

                                    L Offline
                                    L Offline
                                    lfreeman6490
                                    wrote on last edited by
                                    #21

                                    @SGaist I changed everything to be Ui_Pathloss. I now am getting a new error

                                    "C2664: 'Ui_Ui_Pathloss::setupUi': cannot convert parameter 1 from 'Ui_Pathloss *const' to 'QFrame *'

                                    1 Reply Last reply
                                    0
                                    • SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #22

                                      Did you modify anything else than what I suggested ?
                                      What is your actual code ?

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      L 1 Reply Last reply
                                      0
                                      • SGaistS SGaist

                                        Did you modify anything else than what I suggested ?
                                        What is your actual code ?

                                        L Offline
                                        L Offline
                                        lfreeman6490
                                        wrote on last edited by
                                        #23

                                        @SGaist main .cpp

                                        #include "pathloss.h"
                                        #include <QApplication>
                                        
                                        int main(int argc, char *argv[])
                                        {
                                            QApplication a(argc, argv);
                                            Ui_Pathloss w;
                                            w.show();
                                            
                                            return a.exec();
                                        }
                                        
                                        

                                        pathloss.cpp

                                        #include "pathloss.h"
                                        #include "ui_pathloss.h"
                                        
                                        Ui_Pathloss::Ui_Pathloss(QWidget *parent):
                                            QWidget(parent),
                                            ui(new Ui::Ui_Pathloss)
                                        {
                                            ui->setupUi(this);
                                        }
                                        
                                        Ui_Pathloss::~Ui_Pathloss()
                                        {
                                            delete ui;
                                        }
                                        
                                        

                                        pathloss.h

                                        #ifndef PATHLOSS_H
                                        #define PATHLOSS_H
                                        
                                        #include <QWidget>
                                        
                                        namespace Ui {
                                        class Ui_Pathloss;
                                        }
                                        
                                        class Ui_Pathloss : public QWidget
                                        {
                                            Q_OBJECT
                                            
                                        public:
                                            explicit Ui_Pathloss(QWidget *parent = 0);
                                            ~Ui_Pathloss();
                                        
                                        private:
                                            Ui::Ui_Pathloss *ui;
                                        };
                                        
                                        #endif // PATHLOSS_H
                                        

                                        my ui_Pathloss.h file is too long to post here, but this is the namespace at the bottom

                                        namespace Ui {
                                            class Ui_Pathloss: public Ui_Pathloss {};
                                        } // namespace Ui
                                        
                                        QT_END_NAMESPACE
                                        
                                        1 Reply Last reply
                                        0
                                        • L lfreeman6490

                                          @JoeCFD I did that and nothing changed, still getting the same error

                                          JoeCFDJ Offline
                                          JoeCFDJ Offline
                                          JoeCFD
                                          wrote on last edited by
                                          #24
                                          This post is deleted!
                                          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
                                          • Unsolved