我想在sample的StyleSheetEditor例子中,再加一个弹出对话框。在新建这个新对话框的.ui,.h,.cpp后,
我在StyleSheetEditor .h中加入了带下划线的代码
class Mode;
class StyleSheetEditor : public QDialog
{
Q_OBJECT
public:
StyleSheetEditor(QWidget *parent = 0);
private slots:
void on_mode_clicked();
private:
Mode *mode;
Ui::StyleSheetEditor ui;
};
我在StyleSheetEditor .cpp中加入了带下划线的代码
#include "Mode.h"
StyleSheetEditor::StyleSheetEditor(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
mode = new Mode(this);
}
void StyleSheetEditor::on_mode_clicked()
{
mode->show();
mode->activateWindow();
}
编译出错,提示:
error: forward declaration of `struct Mode'
error: invalid use of undefined type `struct Mode'
这是为什么?我反复检查,也看不出来。StyleSheetEditor也是被mainwindow这样调出来的呀。