1. 將 QT Creator 生成的 exe 文件拷貝到一個目錄中 :C:\Users\zyy\Desktop\qtrelease
2.新建 bat 文件:qt.bat 。 編輯文件,注意替換 QT 的安裝目錄。使用這個 bat 文件即可方便的添加依賴項了。
echo off echo Setting up environment for Qt usage... set PATH=E:\qt\5.5\mingw492_32\bin;E:\qt\Tools\mingw492_32\bin;%PATH% "E:\qt\5.5\mingw492_32\bin\windeployqt.exe" "C:\Users\zyy\Desktop\qtrelease\Signal.exe" :End pause
總結:正常的發布方法是在開始菜單中打開 Qt 5.5 for Desktop (MinGW 4.9.2 32 bit)(這是安裝 QT 時生成的一個快捷方式),研究這個快捷方式的參數,發現它指向了一個批處理文件:
C:\Windows\System32\cmd.exe /A /Q /K E:\qt\5.5\mingw492_32\bin\qtenv2.bat
研究 qtenv2.bat 這個文件,就有了本文的第二步。
echo off echo Setting up environment for Qt usage... set PATH=E:\qt\5.5\mingw492_32\bin;E:\qt\Tools\mingw492_32\bin;%PATH% cd /D E:\qt\5.5\mingw492_32