我用的系统是RH9,是系统自带的QT,在照书编写第一个QT程序时遇到以下问题,因为完全是照书上做的,却运行不出来结果,还请大家帮忙看看如何解决,让我入个门,谢谢!
程序的原代码如下:
#include<qapplication.h>
#include<qlabel.h>
int main(int argc,char **argv)
{
QApplication app(argc,argv);
QLabel *hello=new QLabel ("<font color=blue>Hello""<i>Qt Embeded!</i></font>",0);
app.setMainWidgt (hello);
hello->show();
return app.exec();
}
运行后出错:
[root@localhost root]# cd /usr/local/qt/hello
[root@localhost hello]# ls -a
. .. hello.cpp hello.pro
[root@localhost hello]# qmake hello.pro
[root@localhost hello]# make
g++ -c -pipe -Wall -W -O2 -march=i386 -mcpu=i686 -g -DGLX_GLXEXT_LEGACY -fno-use-cxa-atexit -fno-exceptions -DQT_NO_DEBUG -I/usr/lib/qt-3.1/mkspecs/default -I. -I/usr/lib/qt-3.1/include -I.ui/ -I.moc/ -o .obj/hello.o hello.cpp
hello.cpp: In function `int main(int, char**)':
hello.cpp:7: no matching function for call to `QApplication::setMainWidgt(
QLabel*&)'
make: *** [.obj/hello.o] Error 1
[root@localhost hello]#
[ 此贴被XChinux在2007-03-15 12:50重新编辑 ]