I have strange problem with including class. I have the class: main.cpp:
#include "startwidget.h"
#include <QApplication>
#include <QtPlugin>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
StartWidget w;
w.show();
return a.exec();
}
startwidget.h:
#ifndef STARTWIDGET_H
#define STARTWIDGET_H
#include <QWidget>
#include "phonewidget.h"
#include "servicearealogin.h"
namespace Ui {
class StartWidget;
}
class StartWidget : public QWidget
{
Q_OBJECT
public:
explicit StartWidget(QWidget *parent = 0);
~StartWidget();
private:
Ui::StartWidget *ui;
PhoneWidget *phoneWidget;
ServiceAreaLogin *serviceAreaLogin;
};
#endif // STARTWIDGET_H
servicearealogin.h:
#ifndef SERVICEAREALOGIN_H
#define SERVICEAREALOGIN_H
#include <QWidget>
#include <QTimer>
#include "startwidget.h"
namespace Ui {
class ServiceAreaLogin;
}
class ServiceAreaLogin : public QWidget
{
Q_OBJECT
public:
explicit ServiceAreaLogin(QWidget *parent = 0);
~ServiceAreaLogin();
private:
Ui::ServiceAreaLogin *ui;
StartWidget *startWidget;
void startWidgetInit();
#endif // SERVICEAREALOGIN_H
The problem is that when I want to compile my program I get a error:
/main.cpp:1: In file included from ../Fluidwash/main.cpp:1:
/startwidget.h:6: In file included from startwidget.h:6:
servicearealogin.h:22: błąd: unknown type name 'StartWidget' StartWidget *startWidget; ^
I really don't understand why it can't find the StartWidget class if I included this in headers.
Or maybe my include politic is bad?
In my StartWidget QWidget I do serviceAreaLogin->show(), now I need do the same with startWidget to back to previous widget.
I read it Resolve header include circular dependencies and for me I included .h of class that i created pointer. So why doesn't it see the class?