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
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.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.
  • 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
                  • JoeCFDJ JoeCFD

                    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 Offline
                    L Offline
                    lfreeman6490
                    wrote on last edited by
                    #29

                    @JoeCFD I have no instances of f_pathloss, I changed them all to Pathloss

                    @SGaist This basically is where I started from. Every change undoes the previous one. The difference between this and the original version is the 'f_pathloss' is now just 'Pathloss'

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

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

                      ui_Pathloss.h

                      do not change ui_Pathloss.h because it is generated. Change pathloss.ui or Pathloss.ui file
                      Your class name has to match to the name defined in
                      <class>*****</class> in pathloss.ui or Pathloss.ui file

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

                        Depending on what that interface contains, it could be simpler to just rebuilt it from scratch and be done with it.

                        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

                          Depending on what that interface contains, it could be simpler to just rebuilt it from scratch and be done with it.

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

                          @SGaist Yeah I think I might just do that. I've been at this all day. Thanks for trying to help. I appreciate it @JoeCFD

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

                            ======================TestWidget.h============================
                            #include <QWidget>

                            #include "ui_TestWidget.h"

                            class TestWidget : public QWidget
                            {
                            Q_OBJECT

                            public:
                            explicit TestWidget(QWidget *parent = 0);
                            ~TestWidget() {}

                            private:
                            Ui::TestWidget ui;
                            };

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

                              ===================TestWidget.cpp=============================
                              #include "TestWidget.h"

                              TestWidget::TestWidget( QWidget * parent )
                              :QWidget( parent )
                              {
                              ui.setupUi(this);
                              //resize( 500, 500 );
                              }

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

                                ===========main.cpp===========

                                #include <QApplication>

                                #include "TestWidget.h"

                                int main(int argc, char *argv[])
                                {
                                QApplication app(argc, argv);

                                TestWidget widget;
                                widget.show();
                                
                                return app.exec();
                                

                                }

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

                                  ==================TestWidget.ui file

                                  <?xml version="1.0" encoding="UTF-8"?>
                                  <ui version="4.0">
                                   <class>TestWidget</class>
                                   <widget class="QWidget" name="TestWidget">
                                    <property name="geometry">
                                     <rect>
                                      <x>0</x>
                                      <y>0</y>
                                      <width>1037</width>
                                      <height>664</height>
                                     </rect>
                                    </property>
                                    <property name="windowTitle">
                                     <string>Form</string>
                                    </property>
                                    <layout class="QVBoxLayout" name="verticalLayout_2">
                                     <item>
                                      <widget class="QGroupBox" name="groupBox">
                                       <property name="title">
                                        <string>GroupBox</string>
                                       </property>
                                       <layout class="QHBoxLayout" name="horizontalLayout">
                                        <item>
                                         <layout class="QVBoxLayout" name="verticalLayout">
                                          <item>
                                           <widget class="QScrollArea" name="scrollArea">
                                            <property name="widgetResizable">
                                             <bool>true</bool>
                                            </property>
                                            <widget class="QWidget" name="scrollAreaWidgetContents">
                                             <property name="geometry">
                                              <rect>
                                               <x>0</x>
                                               <y>0</y>
                                               <width>1175</width>
                                               <height>584</height>
                                              </rect>
                                             </property>
                                             <layout class="QVBoxLayout" name="verticalLayout_3">
                                              <item>
                                               <widget class="QLabel" name="label">
                                                <property name="text">
                                                 <string>Testing</string>
                                                </property>
                                               </widget>
                                              </item>
                                             </layout>
                                            </widget>
                                           </widget>
                                          </item>
                                         </layout>
                                        </item>
                                       </layout>
                                      </widget>
                                     </item>
                                    </layout>
                                   </widget>
                                   <resources/>
                                   <connections/>
                                  </ui>
                                  
                                  1 Reply Last reply
                                  0
                                  • JoeCFDJ Offline
                                    JoeCFDJ Offline
                                    JoeCFD
                                    wrote on last edited by JoeCFD
                                    #37

                                    You can see where I use TestWidget in .cpp, .h and .ui. They have to be the same.

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

                                      ============================ui_TestWidget.h <=== this file is generated and you do not change it.

                                      #ifndef UI_TESTWIDGET_H
                                      #define UI_TESTWIDGET_H

                                      #include <QtCore/QVariant>
                                      #include <QtWidgets/QApplication>
                                      #include <QtWidgets/QGroupBox>
                                      #include <QtWidgets/QHBoxLayout>
                                      #include <QtWidgets/QLabel>
                                      #include <QtWidgets/QScrollArea>
                                      #include <QtWidgets/QVBoxLayout>
                                      #include <QtWidgets/QWidget>

                                      QT_BEGIN_NAMESPACE

                                      class Ui_TestWidget
                                      {
                                      public:
                                      QVBoxLayout *verticalLayout_2;
                                      QGroupBox *groupBox;
                                      QHBoxLayout *horizontalLayout;
                                      QVBoxLayout *verticalLayout;
                                      QScrollArea *scrollArea;
                                      QWidget *scrollAreaWidgetContents;
                                      QVBoxLayout *verticalLayout_3;
                                      QLabel *label;

                                      void setupUi(QWidget *TestWidget)
                                      {
                                          if (TestWidget->objectName().isEmpty())
                                              TestWidget->setObjectName(QString::fromUtf8("TestWidget"));
                                          TestWidget->resize(1037, 664);
                                          verticalLayout_2 = new QVBoxLayout(TestWidget);
                                          verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
                                          groupBox = new QGroupBox(TestWidget);
                                          groupBox->setObjectName(QString::fromUtf8("groupBox"));
                                          horizontalLayout = new QHBoxLayout(groupBox);
                                          horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
                                          verticalLayout = new QVBoxLayout();
                                          verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
                                          scrollArea = new QScrollArea(groupBox);
                                          scrollArea->setObjectName(QString::fromUtf8("scrollArea"));
                                          scrollArea->setWidgetResizable(true);
                                          scrollAreaWidgetContents = new QWidget();
                                          scrollAreaWidgetContents->setObjectName(QString::fromUtf8("scrollAreaWidgetContents"));
                                          scrollAreaWidgetContents->setGeometry(QRect(0, 0, 1175, 584));
                                          verticalLayout_3 = new QVBoxLayout(scrollAreaWidgetContents);
                                          verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3"));
                                          label = new QLabel(scrollAreaWidgetContents);
                                          label->setObjectName(QString::fromUtf8("label"));
                                      
                                          verticalLayout_3->addWidget(label);
                                      
                                          scrollArea->setWidget(scrollAreaWidgetContents);
                                      
                                          verticalLayout->addWidget(scrollArea);
                                      
                                      
                                          horizontalLayout->addLayout(verticalLayout);
                                      
                                      
                                          verticalLayout_2->addWidget(groupBox);
                                      
                                      
                                          retranslateUi(TestWidget);
                                      
                                          QMetaObject::connectSlotsByName(TestWidget);
                                      } // setupUi
                                      
                                      void retranslateUi(QWidget *TestWidget)
                                      {
                                          TestWidget->setWindowTitle(QCoreApplication::translate("TestWidget", "Form", nullptr));
                                          groupBox->setTitle(QCoreApplication::translate("TestWidget", "GroupBox", nullptr));
                                          label->setText(QCoreApplication::translate("TestWidget", "Testing", nullptr));
                                      } // retranslateUi
                                      

                                      };

                                      namespace Ui {
                                      class TestWidget: public Ui_TestWidget {};
                                      } // namespace Ui

                                      QT_END_NAMESPACE

                                      #endif // UI_TESTWIDGET_

                                      L 1 Reply Last reply
                                      0
                                      • JoeCFDJ JoeCFD

                                        ============================ui_TestWidget.h <=== this file is generated and you do not change it.

                                        #ifndef UI_TESTWIDGET_H
                                        #define UI_TESTWIDGET_H

                                        #include <QtCore/QVariant>
                                        #include <QtWidgets/QApplication>
                                        #include <QtWidgets/QGroupBox>
                                        #include <QtWidgets/QHBoxLayout>
                                        #include <QtWidgets/QLabel>
                                        #include <QtWidgets/QScrollArea>
                                        #include <QtWidgets/QVBoxLayout>
                                        #include <QtWidgets/QWidget>

                                        QT_BEGIN_NAMESPACE

                                        class Ui_TestWidget
                                        {
                                        public:
                                        QVBoxLayout *verticalLayout_2;
                                        QGroupBox *groupBox;
                                        QHBoxLayout *horizontalLayout;
                                        QVBoxLayout *verticalLayout;
                                        QScrollArea *scrollArea;
                                        QWidget *scrollAreaWidgetContents;
                                        QVBoxLayout *verticalLayout_3;
                                        QLabel *label;

                                        void setupUi(QWidget *TestWidget)
                                        {
                                            if (TestWidget->objectName().isEmpty())
                                                TestWidget->setObjectName(QString::fromUtf8("TestWidget"));
                                            TestWidget->resize(1037, 664);
                                            verticalLayout_2 = new QVBoxLayout(TestWidget);
                                            verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
                                            groupBox = new QGroupBox(TestWidget);
                                            groupBox->setObjectName(QString::fromUtf8("groupBox"));
                                            horizontalLayout = new QHBoxLayout(groupBox);
                                            horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
                                            verticalLayout = new QVBoxLayout();
                                            verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
                                            scrollArea = new QScrollArea(groupBox);
                                            scrollArea->setObjectName(QString::fromUtf8("scrollArea"));
                                            scrollArea->setWidgetResizable(true);
                                            scrollAreaWidgetContents = new QWidget();
                                            scrollAreaWidgetContents->setObjectName(QString::fromUtf8("scrollAreaWidgetContents"));
                                            scrollAreaWidgetContents->setGeometry(QRect(0, 0, 1175, 584));
                                            verticalLayout_3 = new QVBoxLayout(scrollAreaWidgetContents);
                                            verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3"));
                                            label = new QLabel(scrollAreaWidgetContents);
                                            label->setObjectName(QString::fromUtf8("label"));
                                        
                                            verticalLayout_3->addWidget(label);
                                        
                                            scrollArea->setWidget(scrollAreaWidgetContents);
                                        
                                            verticalLayout->addWidget(scrollArea);
                                        
                                        
                                            horizontalLayout->addLayout(verticalLayout);
                                        
                                        
                                            verticalLayout_2->addWidget(groupBox);
                                        
                                        
                                            retranslateUi(TestWidget);
                                        
                                            QMetaObject::connectSlotsByName(TestWidget);
                                        } // setupUi
                                        
                                        void retranslateUi(QWidget *TestWidget)
                                        {
                                            TestWidget->setWindowTitle(QCoreApplication::translate("TestWidget", "Form", nullptr));
                                            groupBox->setTitle(QCoreApplication::translate("TestWidget", "GroupBox", nullptr));
                                            label->setText(QCoreApplication::translate("TestWidget", "Testing", nullptr));
                                        } // retranslateUi
                                        

                                        };

                                        namespace Ui {
                                        class TestWidget: public Ui_TestWidget {};
                                        } // namespace Ui

                                        QT_END_NAMESPACE

                                        #endif // UI_TESTWIDGET_

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

                                        @JoeCFD I have it all the same except for one line in my pathloss.ui file. It has my widget class as a "QFrame" and it has to be changed in the design mode it says

                                        <?xml version="1.0" encoding="UTF-8"?>
                                        <ui version="4.0">
                                         <author>free</author>
                                         <class>pathloss</class>
                                         <widget class="QFrame" name="pathloss">
                                          <property name="geometry">
                                        
                                        1 Reply Last reply
                                        0
                                        • JoeCFDJ Offline
                                          JoeCFDJ Offline
                                          JoeCFD
                                          wrote on last edited by
                                          #40

                                          use upper case
                                          <class>pathloss</class> ===> <class>Pathloss</class>
                                          <widget class="QFrame" name="Pathloss"> <====not critical

                                          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