[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_OBJECT

    public:
    RemovePlanningController();
    virtual ~RemovePlanningController();

    private:
    RemovePlanningUi *screen

    public 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";
    }

    @



  • Hi,

    why does removePlanningController.h include removePlanningUi.h? in the code you show, that is not needed!

    And if you only need the class names for pointers, use pre declaration of classes and put the include statements to the cpp files.



  • Hi,

    My bad, I removed too much code. I adjusted the code in my first post.
    But i just use pre declaration now and that seems to work fine. Thought it was nicer to have it in my .h files.



  • 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 ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.