を使用して、私は非常にシンプルな、次のコードを持っている:ヘッダーによる循環依存。 #ifndefのとの#define
main.cppにし
#include "ui_library_browser.h"
#include <QtGui/QApplication>
#include "StartWindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
StartWindow w;
w.show();
return a.exec();
}
StartWindow.h
#ifndef STARTWINDOW_H_
#define STARTWINDOW_H_
#include <qwidget>
#include "MainWindow.h"
class StartWindow : public QWidget
{
Q_OBJECT
public:
StartWindow();
~StartWindow();
MainWindow main_window; //<-- Problem
};
#endif
MainWindow.h
#ifndef MAINWINDOW_H_
#define MAINWINDOW_H_
#include <qdialog.h>
#include "StartWindow.h"
class MainWindow : public QDialog
{
Q_OBJECT
public:
MainWindow();
~MainWindow();
};
#endif
これは#include "StartWindow.h"をインクルードするためにエラーが発生します。 MainWindow.hヘッダー。しかし、私は#ifndefと#defineの使用がこのような問題を止めると考えていましたか?誰かが私のためにこれをクリアすることはできますか?
正確なエラーは何ですか? 'StartWindow.h' _first_をインクルードすると、ヘッダーの最初に含まれている順番に依存していて、おそらく修正が必要なのですが、投稿したコードはOKでなければなりません(すべてのQtが正しく)。 –