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. [Solved]... Does not name a type
Forum Updated to NodeBB v4.3 + New Features

[Solved]... Does not name a type

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 15.0k Views 1 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.
  • E Offline
    E Offline
    ebruurs
    wrote on 12 May 2011, 07:56 last edited by
    #1

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

    @

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on 12 May 2011, 08:53 last edited by
      #2

      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.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • E Offline
        E Offline
        ebruurs
        wrote on 12 May 2011, 10:22 last edited by
        #3

        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.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          smannari
          wrote on 27 May 2014, 14:28 last edited by
          #4

          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 ?

          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