setupUi is not a member of my QT application
-
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
-
@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_NAMESPACEclass Ui_FileDeleteProgressDialog
{
public:
Ui_FileDeleteProgressDialog(){}void setupUi( QDialog * dialog ) { } // setupUi};
namespace Ui {
class FileDeleteProgressDialog: public Ui_FileDeleteProgressDialog {};
} // namespace UiQT_END_NAMESPACE
-
Where in my code should I add that? Would that go in my header file?
-
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'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.
-
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.
@SGaist Doing that tells me that there is no appropriate default constructor. Do I have to change all instances of 'Pathloss' to 'Ui::Pathloss'?
-
Where in my code should I add that? Would that go in my header file?
@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?
-
@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?
@JoeCFD the class is named 'Ui_f_pathloss'. This was automated by QT so I didn't change it
-
@JoeCFD the class is named 'Ui_f_pathloss'. This was automated by QT so I didn't change it
@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. -
@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.@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 -
@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@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. -
@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.@JoeCFD I did that and nothing changed, still getting the same error
-
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.
-
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.
@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 *'
-
Did you modify anything else than what I suggested ?
What is your actual code ? -
@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_Hmy 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 -
@JoeCFD I did that and nothing changed, still getting the same error
-
@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. -
@JoeCFD
throws an error at{ ui->setupUi(this); }"C2664: 'Ui_Ui_Pathloss::setupUi': cannot convert parameter 1 from 'Ui_Pathloss *const' to 'QFrame *'
-
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.
-
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.