[Solved]... Does not name a type
-
Hi,
I've been developing an interface. I decided to make an interface class (removePlanningUi.cpp) and a controller class (removePlanningController.cpp). My mainWindow is calling the controller class (ie. removePlanningController). This uiController calls the interface by removePlanningUi *mui = new removePlanningUi(this);.
Because there is some logic behind different buttons (ie. databasemanagement) I wanted to manage that logic within the controllerclass. So my mui needs to know his controller to call the right slot.
So the problem now arrise is the following, my removePlanningUi.h includes removePlanningController.h which then includes removePlanningUi.h which includes removePlanningController.h etc... (According to some google searches this is the problem of the ... does not name a type error). How can I solve this problem, or is the use of a controller class and a uiclass not a good idea (use it in Java many times before in Model-View-Controller designpattern).Here is the code (I removed code that is not needed for the explanation):
removePlanningUi.h
@
#ifndef REMOVEPLANNINGUI_H_
#define REMOVEPLANNINGUI_H_#include "removePlanningController.h"
class RemovePlanningUi
public:
RemovePlanningUi(RemovePlanningController *);
virtual ~RemovePlanningUi();private:
RemovePlanningController *controller;
};#endif /* REMOVEPLANNINGUI_H_ */
@removePlanningController.h
@
#ifndef REMOVEPLANNINGCONTROLLER_H_
#define REMOVEPLANNINGCONTROLLER_H_#include "removePlanningUi.h"
class RemovePlanningController : public QObject {
Q_OBJECTpublic:
RemovePlanningController();
virtual ~RemovePlanningController();private:
RemovePlanningUi *screenpublic slots:
void button_remove_clicked();
};
#endif /* REMOVEPLANNINGCONTROLLER_H_ */
@removePlanningUi.cpp
@
#include "removePlanningUi.h"RemovePlanningUi::RemovePlanningUi(RemoveController *c) : QDialog(){
controller = c;
connect(buttonRemove, SIGNAL(clicked()), controller ,SLOT(button_remove_clicked()));
}
@removePlanningController.cpp
@
#include "removePlanningController.h"RemovePlanningController::RemovePlanningController() {
screen = new RemovePlanningUi(this);
screen->show();}
void RemovePlanningController::button_remove_clicked() {
qDebug() << "buttonRemove clicked";
}@
-
I am facing a similar problem . I have created a login page (Login.cpp) and a change password page (password.cpp) .
The first login page works fine asking and verifying user credentials with SQLite data base. I have created the open and close functions for the data base in the public section of login.h, so that I can access the same in the password.cpp
Now in the second password.h file I have created a Login login object , which gives this error ,
'Login does not name a type' ,I have included the necessary header files in the .h files of each of these files. But still the error
Can you please suggest something ?