neiou 发表于 2005-8-4 02:19:09

Win QT4 "Hello World!" 编译失败。。

刚上路就碰钉子。
一个 "Hello World!" 总是编译失败。。希望大家帮助 :cry:
我用的是 WinXP   MinGW   QT4

#include <QtGui/QtGui>

int main(int argc, char *argv[]){

    QApplication app(argc, argv);
   
    QPushButton hello("Hello world!", 0);
    hello.resize(100, 30);
   
    app.setMainWidget(&hello);
    hello.show();
    return app.exec();
}

编译出错。。

E:\QT-MAKE>mingw32-make
mingw32-make -f Makefile.Release
mingw32-make: Entering directory `E:/QT-MAKE'
g++ -c -O2 -O2 -frtti -fexceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_D
LL -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN
-I"D:/Qt/4.0.0/include/QtGui" -I"D:/Qt/4.0.0/include/QtCore" -I"D:/Qt/4.0.0/inc
lude" -I"." -I"D:/Qt/4.0.0/include/ActiveQt" -I"release" -I"." -I"D:\Qt\4.0.0\mk
specs\win32-g++" -o release\main.o main.cpp
main.cpp: In function `int qMain(int, char**)':
main.cpp:10: error: 'class QApplication' has no member named 'setMainWidget'
mingw32-make: *** Error 1
mingw32-make: Leaving directory `E:/QT-MAKE'
mingw32-make: *** Error 2

gz6x 发表于 2005-8-4 04:33:20

你看的教程用的是qt3.4,qt4.0 win32里没有这个成员函数,api变了,没法子。 :-(

neiou 发表于 2005-8-4 11:39:35

看为Win QT4程序演示中的 很容易就成功了 :?
我照葫芦画瓢都不行。 :cry:

neiou 发表于 2005-8-4 13:52:53

在群中 解决了。。。。。

XChinux(23947407) 13:41:10
    app.setMainWidget(&hello); //这句话不需要了
    hello.show();
    return app.exec()

niverse 发表于 2005-10-4 17:33:58

怎么解决的??我的tkpppoe也编译失败了,不知道该怎么办。

peah 发表于 2008-1-30 14:21:29

回复 #1 neiou 的帖子

在.pro文件中添加    QT += qt3support    就可以了
页: [1]
查看完整版本: Win QT4 "Hello World!" 编译失败。。