Utilisation invalide de type incomplète et en avant de la déclaration de

J'ai essayé de résoudre ce problème mais il doit y avoir un malentendu dans la façon de comprendre avant de déclaration.

J'obtiens l'erreur suivante:

src/algorithm.cpp: In constructor Algorithm::Algorithm(MainWindow*)’:
src/algorithm.cpp:22:20: error: invalid use of incomplete type struct Ui::MainWindow
src/mainwindow.h:23:10: error: forward declaration of struct Ui::MainWindow

J'ai ces fichiers (j'ai omis certaines lignes et les fichiers et collé uniquement code correspondant):

algorithm.cpp

#include "algorithm.h"
#include "mainwindow.h"

Algorithm::Algorithm(MainWindow *mainWindow)
{
   this->mainWindow = mainWindow;

   QAction *action = new QAction(this);
   action->setObjectName(QStringLiteral("action"));
   action->setText(this->getName());

   mainWindow->m_ui->menuAlgorithms->addAction(action);

   mainWindow->connect(action, SIGNAL(triggered()), this, SLOT(this->start()));
}

algorithme.h

#ifndef ALGORITHM_H
#define ALGORITHM_H

#include <QObject>

#include "graphwidget.h"
#include "edge.h"
#include "vertex.h"

class MainWindow;

class Algorithm : public QObject
{
public:
   MainWindow *mainWindow;

   Algorithm(MainWindow *mainWindow);

   void start();
   virtual void solve();
   virtual QString getDescription();
   virtual QString getName();
};

mainwindow.cpp

#include "mainwindow.h"
#include "algorithm.h"
#include "../ui/ui_mainwindow.h"
#include "vertex.h"
#include "edge.h"
#include "warning.h"

mode_type mode;

MainWindow::MainWindow(QWidget *parent) :
   QMainWindow(parent),
   m_ui(new Ui::MainWindow)
{
   gundirected = NULL;
   gdirected = NULL;

   m_ui->setupUi(this);
...

mainwindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSystemTrayIcon>
#include <QSignalMapper>
#include <QUndoView>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QKeyEvent>
#include <QGraphicsSceneMouseEvent>
#include <QLabel>
#include <QVBoxLayout>
#include <QPushButton>

#include "graphwidget.h"

enum mode_type {NORMAL, VERTEX, EDGE}; //vyctovy typ pro urceni editoacniho modu
extern mode_type mode;

namespace Ui
{
   class MainWindow;
}

class MainWindow : public QMainWindow
{
   Q_OBJECT

public:
   explicit MainWindow(QWidget *parent = 0);
   ~MainWindow();

   Ui::MainWindow *m_ui;
...

OriginalL'auteur alop789312 | 2014-05-29