各位前辈好! 我是Qt初学者,遇到一些问题,百度和google了找不到解决的方法,所以上来请教一下:
windows xp + qt-windows-opensource-5.0.1-mingw47_32-x86-offline.exe
安装后添加了环境变量,对照了《零基础学Qt4》上面的例子,结果出现一些问题。
源代码:
#include <QCoreApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QPushButton pushButton(QObject::tr("Hello Qt!"));
pushButton.show();
QObject::connect(&pushButton,SIGNAL((clicked()),&a,SLOT(quit());
return a.exec();
}
保存为 HelloQt.cpp 后,使用cmd 开始编译:
qmake -project
//OK
qmake HelloQt.pro
//OK
mingw32-make.exe
>
mingw32-make.exe -f Makefile.Release
mingw32-make.exe[1]: Entering directory 'E:/QtCode/HelloQt'
g++ -c -pipe -fno-keep-inline-dllexport -O2 -frtti -Wall -Wextra -fexceptions -m
threads -DUNICODE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT
_OPENGL_ES_2_ANGLE -DQT_NEEDS_QMAIN -I. -I"." -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\
include" -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtGui" -I"D:\Qt\Qt5.0.1\5.0.1
\mingw47_32\include\QtCore" -I"release" -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\mkspec
s\win32-g++" -o release\main.o main.cpp
main.cpp:2:23: **fatal error: QPushButton: No such file or directory**
compilation terminated.
Makefile.Release:175: recipe for target 'release/main.o' failed
mingw32-make.exe[1]: *** [release/main.o] Error 1
mingw32-make.exe[1]: Leaving directory 'E:/QtCode/HelloQt'
makefile:34: recipe for target 'release' failed
mingw32-make.exe: *** [release] Error 2
出现错误,不知此错误为何缘故? 明明头文件已经包含了 QPushButton.h 了。
求教各位前辈~