程序如下:#include <qapplication.h>
#include <qlabel.h>
int main(int argc,char **argv)
{
qapplication a(argc,argv);
qlabel *label=new qlabel("hello world!",0);
label->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);
label->setGeometry(10,10,200,80);
app.setMainWidget(label);
label->show();
int result=app.exec();
return result;
}
我的qt安装在/tmp下,在网上搜索了一下,我还
安装了g++,
编译时
出错如下:
执行命令:progen -t app.t -o hello.pro
tmake -o makefile hello.pro后,ls一下:
hello.cpp hello.pro makefile
然后执行命令:
make,出现的
错误有:
hmily@xtu:~/文档/HELLO$ make
g++ -c -pipe -Wall -W -O2 -DNO_DEBUG -I/usr/include/qt -o hello.o hello.cpp
hello.cpp:1:26: error: qapplication.h:
没有那个文件或
目录hello.cpp:2:20: error: qlabel.h: 没有那个文件或目录
hello.cpp: In function ‘int main(int, char**)’:
hello.cpp:5: error: ‘qapplication’ was
not declared in this scope
hello.cpp:5: error: expected ‘;’ before ‘a’
hello.cpp:6: error: ‘qlabel’ was not declared in this scope
hello.cpp:6: error: ‘label’ was not declared in this scope
hello.cpp:6: error: expected type-specifier before ‘qlabel’
hello.cpp:6: error: expected ‘;’ before ‘qlabel’
hello.cpp:7: error: ‘Qt’ has not been declared
hello.cpp:7: error: ‘Qt’ has not been declared
hello.cpp:9: error: ‘app’ was not declared in this scope
hello.cpp: At global scope:
hello.cpp:3: warning: unused parameter ‘argc’
hello.cpp:3: warning: unused parameter ‘argv’
make: *** [hello.o] 错误 1
而且后来我把qt里的qapplication.h,qlabel.h复制到HELLO目录下,则出现的错误为:
hmily@xtu:~/文档/HELLO$ make
g++ -c -pipe -Wall -W -O2 -DNO_DEBUG -I/usr/include/qt -o hello.o hello.cpp
hello.cpp:1:26: error: qapplication.h: 没有那个文件或目录
hello.cpp:2:20: error: qlabel.h: 没有那个文件或目录
hello.cpp: In function ‘int main(int, char**)’:
hello.cpp:5: error: ‘qapplication’ was not declared in this scope
hello.cpp:5: error: expected ‘;’ before ‘a’
hello.cpp:6: error: ‘qlabel’ was not declared in this scope
hello.cpp:6: error: ‘label’ was not declared in this scope
hello.cpp:6: error: expected type-specifier before ‘qlabel’
hello.cpp:6: error: expected ‘;’ before ‘qlabel’
hello.cpp:7: error: ‘Qt’ has not been declared
hello.cpp:7: error: ‘Qt’ has not been declared
hello.cpp:9: error: ‘app’ was not declared in this scope
hello.cpp: At global scope:
hello.cpp:3: warning: unused parameter ‘argc’
hello.cpp:3: warning: unused parameter ‘argv’
make: *** [hello.o] 错误 1
所以我很郁闷,还请各位大侠帮帮忙解决一下
问题...非常感谢...