Qt初體驗
Qt 略有所聞,只是很少接觸,以下是用Visual C++ 6.0 的 nmake 安裝 Qt 的過程,目前可能無法記載很詳細,因為暫時想看看怎麼用 Qt 來寫 UI。
Qt source for windows: qt-win-opensource-src-4.3.4.zip
Qt Visual Studio Patch: acs-4.3.x-patch3.zip
windows platform: Microsoft Windows XP SP2
IDE Tool: Microsoft Visual C++ 6.0 Enterprise update to Service Pack 6
- 安裝好 Visual C++ 6.0,再將 qt-win-opensource-src-4.3.4.zip 解壓縮到 c:\Qt\4.3.4 的目錄下。
- 將 acs-4.3.x-patch3.zip 解壓縮到 c:\Qt\4.3.4 目錄下。
- 開啟 console mode,切換到 Visual C++ 6.0 的安裝目錄,在我的電腦上的路徑如下
C:\Program Files\Microsoft Visual Studio\VC98\Bin,然後執行 VCVARS32.BAT 讓 VC 暫時設定 PATH(我有先將 PATH 清除)。 - 之後再切換到 c:\Qt\4.3.4 目錄,執行 nmake /? ,是否可以正確執行 nmake。
- 執行 Visual Studio patch of Qt,輸入 installpatch43.bat
- 再執行 qconfigure msvc,可是一直出現 NMAKE : fatal error U1073: don’t know how to make ‘..\src\core\global\qconfig.cpp‘ Stop. 的訊息,無法 configure 我的環境,所以我直接用 configure -platform win32-msvc 來 configure。
- 完成之後再輸入 nmake,接下來是一連串的等待……。
- 接下來設定 Qt 的路徑,開始 | 設定 | 控制台 | 系統 | 進階 | 環境設定 | PATH | 編輯 | 加上 c:\Qt\4.3.4\bin
- 闗掉剛剛的 console mode,重新開啟一個 console mode,輸入 qmake -v,是否能正常執行。
- Create Visual Studio projects
- 建立一個 testQt 的資料夾。
- 將 console mode 路徑切換到 testQt 目錄下,先用記事本寫一個測試程式碼,可到此網址看一下 http://qtnode.net/wiki?title=Hello_World ,完成後再輸入 qmake -project -t vcapp -o testQt.pro,之後會產生一個 testQt.pro。
- 再輸入 qmake,會再產生一些檔案及目錄,其中有一個為 testQt.dsp,請用 Visual C++ 6.0 開啟。
- 試著編譯剛剛所寫的測試檔,且 Build 一個可執行檔出來執行看看。
- 至於 Qt Library 的路徑已在 qmake 時所產生的 dsp 檔內都設定好了,所以 VC++ 6.0 開啟時都在裡面設定了,可以到 Porject Settings… 裡面的 Link 去看看 Qt 所幫你設定的路徑。


