qt提供了专门的部署工具, windeployqt
QT官方资料显示如下:
Usage: windeployqt [options] [files]
Qt Deploy Tool 5.9.0
The simplest way to use windeployqt is to add the bin directory of your Qt
installation (e.g. <QT_DIR\bin>) to the PATH variable and then run:
windeployqt <path-to-app-binary>
If ICU, ANGLE, etc. are not in the bin directory, they need to be in the PATH
variable. If your application uses Qt Quick, run:
windeployqt --qmldir <path-to-app-qml-files> <path-to-app-binary>
使用步骤:
1-对软件进行Release编译,将生成的exe文件,单独拷贝到特定文件夹。(注意最好不含中文)
2-使用命令行,cd到上述包含exe文件的文件夹。
3-使用windeployqt命令:
对于Qt-weidget:windeployqt a.exe 即可
对于QtQuick(qml):windeployqt --qmldir 该项目源文件中包含QML文件的地址 a.exe
--qmldir 参数 内容是指向项目中qml的文件夹路径, 这样可以让Qt识别运行项目里qml文件需要的QtQuick库.