1.é¦å
å¨è¯¥é¾æ¥å¤ä¸è½½ Qt libraryå Qt createrï¼
http://qt-project.org/downloadsï¼ï¼
æ使ç¨ç Qt libraryæ¯qt-win-opensource-4.8.5-mingw.exeï¼
Qt createræ¯qt-creator-windows-opensource-2.7.2.exe;
å®è£
QTä¹åï¼è¿éè¦ä¸è½½MinGW-gccï¼æ使ç¨çæ¯MinGW-gcc440_1.zipï¼
http://ishare.iask.sina.com.cn/f/34637805.htmlè¿å¿å¯ä»¥å
è´¹ä¸è½½ï¼
2.å好äºææåå¤åï¼æ们å¼å§å®è£
ï¼
(1).å¨å®è£
Qtä¹åï¼æ们ç®åäºè§£ä¸MinGWãï¼
http://baike.baidu.com/view/98554.htmï¼
MinGWæ¯ä¸ä¸ªå¯ä»¥èªç±ä½¿ç¨åèªç±åå¸çWindowsç¹å®å¤´æ件å使ç¨GUNå·¥å
·é导å
¥åºçéåï¼å
许å¨GUN/LinuxåæWindowså¹³å°çææ¬å°çWindowsç¨åºèä¸éè¦ç¬¬ä¸æ¹Cè¿è¡æ¶åºã
æ们å¨å®è£
Qtä¹åï¼éè¦å¨ç³»ç»ä¸åæ¾è¿ä¸ªMinGWå·¥å
·åºãè¿éï¼æåæ¾çä½ç½®æ¯ D:\Install softwareï¼ï¼å½ç¶ï¼ä½ å®å
¨å¯ä»¥åæ¾å¨å
¶ä»å°æ¹ï¼åªè¦ä½ èªå·±è®°ä½ä½ç½®å°±å¯ä»¥äºï¼ï¼å 为ä¸é¢çå®è£
è¿ç¨éè¦ç¨å°è¿ä¸ªåºã
(2).æ¥ä¸æ¥ï¼å¼å§å®è£
Qt libraryãç´æ¥åå»exeæ件就å¯ä»¥äºï¼ç¶åæ ¹æ®æ示è¿è¡å®è£
ï¼è¿éæéæ©å®è£
çä½ç½®æ¯D:\QTï¼å®è£
è¿ç¨ä¸æ个å°æ¹éè¦å¡«å
¥MinGWçä½ç½®ï¼è¯¥ä½ç½®å°±æ¯ä¸ä¸æ¥ä¸MinGWåæ¾çä½ç½®ï¼æè¿éçä½ç½®æ¯D:\Install software\mingwï¼ç¶åå¾è½»æ¾å°±å®æå®è£
ï¼
(3).ç¶åï¼ä¸ºäºä»¥åè½æ´æ¹ä¾¿ç使ç¨Qtï¼æ们éè¦å
ç¼è¯ä¸ä¸ãå¨å¼å§èåä¸ï¼æ¾å°Qt by Digia v4.8.5 (MinGW OpenSource)è¿ä¸ªæ件夹ï¼æå¼ï¼éé¢ä¼æQt 4.8.5ï¼Build Debug Librariesï¼çä¸ä¸ªæ¹å¤çæ件ï¼ç¹å»åä¼è¿å
¥windowsä¸çDOSçé¢ï¼ç¶åæ ¹æ®éé¢çæ示ï¼æ ¹æ®èªå·±çéæ©æ¥ç¼è¯è¿ä¸ªåºãå¾ç®åï¼å°±2æ¥å§ãä¸è¿è¿ä¸ªæ¶é´æç¹é¿ï¼å 为åºæ¯è¾å¤§ï¼æçµèæ¯è¾æ
¢ï¼å·®ä¸å¤ç¼è¯äºå¿«4个å°æ¶ï¼ç¼è¯æ¶å°±ålinuxä¸çå½ä»¤è¡çé¢ä¸æ ·çï¼ä¸è¡ä¸è¡çæ令å¾ä¸é£ã
(4).ç¼è¯å®æåï¼æ们éè¦é
置系ç»ç¯å¢åéãå³é®åå»æççµèï¼éæ©å±æ§ï¼è¿å
¥é«çº§ç³»ç»è®¾ç½®ï¼åå»å³ä¸è§çç¯å¢åéï¼å¨ç¯å¢åépathä¸æ·»å ;D:\QT\bin;D:\Install software\mingw\bin ç¶ååæ·»å 两个ç¯å¢åé
QTDIR=D:\QTï¼ç¼è¯æ¶çé»è®¤ç®å½ï¼è¿ä¸ªå¯ä»¥éæ设置ï¼ç¨æ¥åæ¾å·¥ç¨æ件çï¼;
QMAKESPEC=win32-g++;
å°è¿éï¼windowsä¸çQtå¼åç¯å¢åºæ¬å°±é
置好äºã
ä¸é¢ï¼æ们å¨Dï¼\QTçç®å½ä¸å建ä¸ä¸ªprojectçæ件夹ï¼åå¨projectä¸å建helloæ件夹ï¼åå¨helloæ件夹ä¸å建ä¸ä¸ªcppæ件ï¼åå
¥ä¸ä¸æµè¯ç¨åºï¼
#include <QApplication> //å
å«QApplication头æ件
#include <QPushButton> //å
å«QPushButton头æ件
int main(int argc, char *argv[]) // è¿æ¯æ åçmainå½æ°
{
QApplication app(argc, argv); // æé åºç¨,åMFCä¸çWinApp
QPushButton hello("Hello world!"); // æé PushButton
hello.resize(100, 30); // 设置æé®å¤§å°
hello.show(); // æ¾ç¤ºæé®
return app.exec(); // æ§è¡åºç¨,åMFCä¸çRun
}
ç¶åæå¼å¼å§èåä¸ç Qt 4.8.5 Command Prompt ï¼éè¿cd å½ä»¤æ¾å°cppæå¨çè·¯å¾å°åï¼åè¾å
¥
qmake -project
make
æåï¼ç¼è¯æåéè¿ï¼ä¼å¨helloæ件夹ä¸çreleaseæ件夹ä¸çæä¸ä¸ª.exeæ件ï¼åå»æ§è¡å³å¯ãä¹å¯ä»¥å¨DOSä¸æ§è¡ï¼è¿å
¥æ件夹ç®å½ï¼ç´æ¥è¾å
¥ï¼hello.exe å³å¯ï¼è¿éï¼æè¿ååºäºä¸äºå¸¸ç¨æ令
dir æ¥çæ件å表ï¼ålinuxä¸çâlsâ
cd æ¹åæ件ç®å½ âcd ..âè¿åå°ä¸ä¸å± âcd \âå°æå¨ç£çï¼ä¸è¬ä¸ºcï¼
del å é¤ä¸ä¸ªæ件
mkdirå建ä¸ä¸ªæ件夹
rmdir å é¤ä¸ä¸ªç©ºæ件夹
notepad xx.cpp ç¨è®°äºæ¬æå¼ï¼å¦æ没æåæ¯å建ï¼xx.cppæ件 ä¹å¯ä»¥æ¯.hæ件
3.å¦æè§å¾ä½¿ç¨å½ä»¤è¡ä¸ä¹ æ¯ï¼é£ä¹å°±å¯ä»¥å®è£
Qt createrï¼è¿æ¯ä¸ä¸ªå¾å½¢åç设计ç¼è¯çé¢ï¼ç´æ¥ä½¿ç¨EXEæ件å®è£
ãå®è£
å®æåï¼æå¼è½¯ä»¶ï¼åå»å·¥å
·æ ï¼åå»é项æé®ï¼è¿å
¥ä¸é¢ç页é¢ï¼
åå»æ建åè¿è¡ï¼è¿æ¯æ°çæ¬ï¼èçæ¬æ¯âQt4âï¼ï¼å°±æ¯ä¸é¢è¿ä¸ªé¡µé¢ï¼å°Qtçæ¬ä¸çqmakeè·¯å¾æå¨è®¾ç½®ä¸ºQtå®è£
è·¯å¾ä¸çbinæ件夹ä¸çqmake.exeæ件å³å¯ï¼æ·»å ï¼ç¡®å®ï¼ï¼
è¿æ¶ä½ å¯ä»¥å¨createrä¸æ·»å helloç项ç®ï¼ççè°è¯æ¶åè½å¤éè¿ï¼è½å¦æ£å¸¸è¿è¡ï¼å¦æåºç°è°è¯ä¸éè¿ï¼gbdå¼å¸¸ä¸æï¼é£ä¹ä½ è¿éè¦ä¸è½½gdbãå 为å¨ä¹åçQt Creatorä¸ï¼æ¯ä»¥ä¸ä¸ªQt SDKçæ´ä½æ¥æä¾çï¼éé¢å°±å
æ¬äºMinGWåè°è¯å¨ï¼èä¸ä¹æ éé
ç½®ï¼ç°å¨çæ°çæ¬é½æ¯åæ£å®è£
çï¼æ以就éè¦èªå·±åç¬åæ¾æ¾äºãç½ä¸çä¸ä¸ªè¯´æ³æ¯2.5以ä¸ççæ¬å¿
须使ç¨7.2 IIRCç以ä¸çGDBï¼éè¦éè¦èªå·±åç¬ä¸è½½ï¼è¿éææ¾å°ä¸¤ä¸ªä¸è½½å°åã
http://qt-project.org/wiki/QtCreatorBuildGdbä¸è½½äºDownloadsä¸ç GDB 7.5 binariesï¼æ件å为qtcreator-gdb-7.4-MINGW32_NT-6.1-i686.tar.gzï¼ç´æ¥ç¨winRAR解åï¼æ件夹å
容å¦ä¸ï¼
ç¶åæ们åå°åæçé
置页é¢ï¼éæ©é
ç½®å¥ä»¶ï¼Kitï¼ï¼éæ©æå¨è®¾ç½®ï¼æ¡é¢é»è®¤ï¼ï¼å¦ä¸æ示ï¼
å°è°è¯å¨æ¹ä¸ºæ们ååä¸è½½çgdbä¸çgdb-686-pc-mingw32.exeï¼æåç¡®å®å³å¯ï¼ç¼è¯é¡ºå©éè¿ã
å°æ¤ï¼ææçå·¥ä½å·²ç»å®æï¼ç°å¨å¯ä»¥æ¾å¿ä½¿ç¨Qtå¼åç¯å¢äºã