请问一下,我装好了Dev C++ 和 QT4.2.2 自带的例子已经能够编译了,但是今天编译《C++ GUI QT3编成》里面第一个例子就不能通过,是不是兼容性有问题啊?
我的程序是
————————————————————————————————#include <qapplication.h>
#include <qlabel.h>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello Qt!", 0);
app.setMainWidget(label);
label->show();
return app.exec();
}
————————————————————————————————编译后的出错信息是
C:\b>make
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory `C:/b'
g++ -c -O2 -O2 -frtti -fexceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_D
LL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN
-I"C:/Qt/4.2.2/include/QtCore" -I"C:/Qt/4.2.2/include/QtCore" -I"C:/Qt/4.2.2/in
clude/QtGui" -I"C:/Qt/4.2.2/include/QtGui" -I"C:/Qt/4.2.2/include" -I"." -I"C:/Q
t/4.2.2/include/ActiveQt" -I"release" -I"." -I"..\Qt\4.2.2\mkspecs\default" -o r
elease\hello.o hello.cpp
hello.cpp: In function `int qMain(int, char**)':
hello.cpp:8:
error: 'class QApplication' has no member named 'setMainWidget'mingw32-make[1]: *** [release\hello.o] Error 1
mingw32-make[1]: Leaving directory `C:/b'
mingw32-make: *** [release] Error 2
——————————————————————————————————————————
error: 'class QApplication' has no member named 'setMainWidget'
这句话我就想不通了,怎么没有这个Member的?
______________________________________
看到有个帖子里面的程序是这样的,我倒是能编译的,不懂了。。。。
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello Qt!");
label->show();
return app.exec();
}
[ 此贴被XChinux在2007-03-21 12:29重新编辑 ]