2008年10月2日 星期四

第一個QT程式

在編譯完畢之後,我開始要寫我第一個QT程式來試驗一下,我發現不是我想像中得那樣簡單,我直接引用別人論壇上的回覆,如果有心的話,你很容易可以google到這段話本來的出處
Hi, There

Following is the method what I successfully did it and for your reference:

1. download "VC++ 2008 Exp" and "qt-win-opensource-src-4.4.0" from officical websites
2. install VC++ 2008 Exp first
3. unzip "qt-win-opensource-src-4.4.0", i.e. "C:\Qt\4.4.0"
4. add "c:\Qt\4.4.0";"c:\Qt\4.4.0\Bin" to your Env Path, and QMAKESPEC=win32-msvc2008
5. open VC++ 2008 Command Prompt/Console from it's Tool Option.
6. go to Qt Directory: "cd c:\Qt\4.4.0"
7. run "configure.exe", then select "y" for yes. (maybe wait for 30~60mins)
8. run "nmake" (maybe wait for 1~4hrs)
9. open VC++ 2008 IDE, select [Tool]->[Option]->[Projects]->[VC++path]
and add following settings:
--> [Execute]: add "c:\Qt\4.4.0" and "c:\Qt\4.4.0\Bin"
--> [Include]: add "c:\Qt\4.4.0" and "c:\Qt\4.4.0\Include"
--> [Lib]: add "c:\Qt\4.4.0" and "c:\Qt\4.4.0\Lib"
10. now, using an editor to create a code, i.e.
#include
#include
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello Qt!");
label->show();
return app.exec();
}
11. then need to create a project for VC++, in the Command Prompt run:
(A) qmake -project
(B) qmake -t vcapp
now, supposed you should get a *.vcproj
12. using VC++2008 IDE to open the *.vcproj
13. build the project..
14. Run it.. then you will see a window with "Hello Qt!" mesg..

:-)


另外我發現,本來很可愛的1xxMB在經過解壓縮跟編譯之後,變成了3~4G的怪物目錄,其實你可以加上nmake clean刪除不必要的object檔案等等,就可以還原到莫約600MB左右的可接受範圍了

沒有留言: