qt4.3.2 安裝 (vs2005+winxp)[轉]

請直接使用src包,不要使用mingw的包;解開源碼包,啥都不用改,用vs2005的命令窗口執行configure.exe,然後裏面就自動找到了 msvc2005作爲編譯器(在顯示內容的開始幾行),然後configure很久,完畢後,nmake,大約1小時,編譯完成,再執行nmake confclean,清理中間文件。

最重要的是使用
Visual Studio 2005 命令提示開啓。
這個會自動設定很多VC2005的系統變量。
這樣,編譯的時候,就不會提示找不到相關文件。
最後纔是改qtvar.bat
@echo off
rem
rem This file is generated
rem
echo Setting up a Qt environment…
echo — QTDIR set to C:/Qt.3.2
echo — Added D:/Qt.3.2/bin to PATH
echo — QMAKESPEC set to win32-msvc2005
set QTDIR=C:/Qt.3.2
set PATH=C:/Qt.3.2/bin;%PATH%
set QMAKESPEC=win32-msvc2005
if not “%1″==”vsvars” goto END
call “C:/Program Files/Microsoft Visual Studio 8/Common7/Tools/vsvars32.bat”
:END
if not “%1″==”vsstart” goto ENDSTARTVS
call “C:/Program Files/Microsoft Visual Studio 8/Common7/Tools/vsvars32.bat”
devenv /useenv
:ENDSTARTVS
上面這個文件中的內容可以手動設置,
即設置變量
QTDIR=c:/qt.3.2
QMAKESPEC=win32-msvc2005
添加PATH=C:/QT.3.2/bin
完成上述工作後,qt環境設置好了。
2:在vs2005中使用qt4.3.2
首先在vs2005中加入頭文件,庫文件的查找路徑:
tools->options->projects and solutions->vc++ directories->include files加入c:/qt.3.2/include
在library中加入c:/qt.3.2/lib
完成上述工作後:我們着手建立一個空的makefile project
new->project ->general->makefile project
進入工程屬性頁 property pages
First you create a new Makefile Project in a empty solution. Then go to the project Property Pages (right click project-〉Properties). Make sure that Debug is the current Configuration and choose “NMake” in the left menu. Then open the Window for “Build command Line” by clicking the “…” Button. Here you enter:
%QTDIR%/bin/qmake
nmake debug
In “Rebuild Command Line” you enter:
%QTDIR%/bin/qmake
nmake debug-clean
nmake debug
And in “Clean Command Line”:
%QTDIR%/bin/qmake
nmake debug-clean
Now the last change, in “Output” enter:
debug/[you app Name].exe
Now do the same thing for release Configuration, but substitute “debug” with “release” ( also in Output Path!)
Now confirm this dialog with OK and create a new File. To do so right click your project and choose Add->Add new Files. Here choose “Text File (.txt)” and as name enter “src.pro”, or something similar. In this file enter:
TEMPLATE = app
CONFIG  += qt [do you config here, mine would be: "qt warn_on"]
QT  += [do you qt-config here]
SOURCES  = main.cpp
HEADERS  =
TARGET  = [your App Name]
win32:debug:CONFIG += console [->if you want to receive qDebug() messages on Windows...]
Save this file and add another file to your project: main.cpp, do it as you did it with the pro File, but choose “C++ File (.cpp)” as file type.
If you want to add another source file to your project, just add it with the add menu, and don’t forget to add the files to the right section in your pro-File. This pro file can be used like any normal pro-File, without any problems.
按以上步驟操作後
隨便做一個測試:
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton *button = new QPushButton(”Quit”);
QObject::connect(button, SIGNAL(clicked()),
&app, SLOT(quit()));
button->show();
return app.exec();
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章