setupUi is not a member of my QT application
-
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' -
@lfreeman6490 said in setupUi is not a member of my QT application:
private:
Pathloss *ui;private:
Ui::Pathloss *ui{};make a habit to add {} to initialize all pointers.
-
I changed that and all the other instances of 'Pathloss' to 'Ui::Pathloss' and still am getting the same error. If I change only that then I get a few other errors like
'Pathloss::ui' member could not be initialized 'initializing': cannot convert from 'Pathloss' to 'Ui::Pathloss'along with still having the error from setupUi
-
With that I get that there is no appropriate default constructor available
-
With that I get that there is no appropriate default constructor available
@lfreeman6490 always make destructor ~Pathloss(); virtual
virtual ~Pathloss();
What is the error message? -
The specific error messages are
C2512: 'Ui::Pathloss' no appropriate default constructor available C1903: unable to recover from previous error(s); stopping compilationthanks for your help so far, i appreciate it
-
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.