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. setupUi is not a member of my QT application

setupUi is not a member of my QT application

Scheduled Pinned Locked Moved Unsolved General and Desktop
41 Posts 3 Posters 6.6k 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
    #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
                                  • 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.

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

                                    @JoeCFD Change your class to Pathloss in your ui file, not Ui_Pathloss.

                                    L 1 Reply Last reply
                                    0
                                    • JoeCFDJ JoeCFD

                                      @JoeCFD Change your class to Pathloss in your ui file, not Ui_Pathloss.

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

                                      @JoeCFD
                                      throws an error at

                                      {
                                          ui->setupUi(this);
                                      }
                                      

                                      "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
                                        #27

                                        Beside what wrote @JoeCFD, it seems you are piling up the various suggestions you got.

                                        You should go back to your starting state before doing anything else.

                                        You should also take the time to read the Qt Designer documentation to understand what you should get.

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

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

                                          Your ui file looks similar like this:
                                          https://doc.qt.io/archives/3.3/designer-manual-16.html
                                          Widgets
                                          <!DOCTYPE UI><UI version="3.1" stdsetdef="1">
                                          <class>WinIntroPage</class>
                                          <widget class="QWidget">
                                          <property name="name">
                                          <cstring>WinIntroPage</cstring>
                                          </property>

                                          see the class tag: change it from f_pathloss to Pathloss
                                          That is the only thing you need to do. Then recompile your code.

                                          L 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