按照2.3.2节建好各个文件中的代码,然后运行,出现报错:
error: ui_hellodialog.h: No such file or directory
#include "ui_hellodialog.h"
QT版本为5.2
没有自动生成ui_hellodialog.h头文件
重建一个UI设计师界面解决了上述问题,但新问题又出现了,
In constructor 'HelloDialog::HelloDialog(QWidget*)':
rror: invalid use of incomplete type 'class Ui::HelloDialog'
ui = new Ui::HelloDialog;
n file included from ..\helloworld\hellodialog.cpp:1:0:
error: forward declaration of 'class Ui::HelloDialog'
class HelloDialog; //鏂版坊
error: invalid use of incomplete type 'class Ui::HelloDialog'
ui->setupUi(this);
error: forward declaration of 'class Ui::HelloDialog'
class HelloDialog; //鏂版坊
^
运行作者老师的例子就可以运行,但是就算我直接拷贝代码过来也会弧线上述的错误,这是为何呢?
^
^
hellodialog.h代码:
#ifndef HELLODIALOG_H#define HELLODIALOG_H
#include <QDialog>
namespace Ui {class HelloDialog;}
class HelloDialog : public QDialog{ Q_OBJECTpublic: explicit HelloDialog(QWidget *parent = 0);
signals:
public slots:
private: Ui::HelloDialog *ui;
};
#endif // HELLODIALOG_H