《Qt Creator快速入门》2.3.2节出现的问题 C++ QT
本帖最后由ceiwei于2016-12-2817:07编辑按照2.3.2节建好各个文件中的代码,然后运行,出现报错:error:ui_hellodialog.h:Nosu...
本帖最后由 ceiwei 于 2016-12-28 17:07 编辑
按照2.3.2节建好各个文件中的代码,然后运行,出现报错:
error: ui_hellodialog.h: No such file or directory
#include "ui_hellodialog.h"
QT版本为5.2
没有自动生成ui_hellodialog.h头文件
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
hellodialog.cpp代码:
#include "hellodialog.h"
#include "ui_hellodialog.h"
HelloDialog::HelloDialog(QWidget *parent) :
QDialog(parent)
{
ui=new Ui::HelloDialog;
ui_>setupUi(this);
}
main.cpp代码:
#include<QApplication>
#include"hellodialog.h"
int main(int argc. char argv[])
{
QApplication a(argc, argv);
HelloDialog w;
w.show();
return a.exec();
}
工程文件代码:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = helloworldTEMPLATE = app
HEADERS += \ hellodialog.h
SOURCES += \ hellodialog.cpp \ main.cpp
FORMS += \ helloworld.ui
上述问题已经解决,是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; //鏂版坊 展开
按照2.3.2节建好各个文件中的代码,然后运行,出现报错:
error: ui_hellodialog.h: No such file or directory
#include "ui_hellodialog.h"
QT版本为5.2
没有自动生成ui_hellodialog.h头文件
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
hellodialog.cpp代码:
#include "hellodialog.h"
#include "ui_hellodialog.h"
HelloDialog::HelloDialog(QWidget *parent) :
QDialog(parent)
{
ui=new Ui::HelloDialog;
ui_>setupUi(this);
}
main.cpp代码:
#include<QApplication>
#include"hellodialog.h"
int main(int argc. char argv[])
{
QApplication a(argc, argv);
HelloDialog w;
w.show();
return a.exec();
}
工程文件代码:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = helloworldTEMPLATE = app
HEADERS += \ hellodialog.h
SOURCES += \ hellodialog.cpp \ main.cpp
FORMS += \ helloworld.ui
上述问题已经解决,是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; //鏂版坊 展开
3个回答
展开全部
老兄你把整个项目工程文件夹打包传上来吧,这样帖代码太难看了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个问题也困扰了我一天,最后在csdn上找到解决办法。网页链接
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询