步骤
制作安装包的步骤:
- 去官网下载Qt Installer Framework的安装包并安装(已经安装的请跳过这步)
- 使用windeployqt.exe集齐所需依赖
- 使用binarycreator.exe创建安装包
具体操作流程:
安装Qt Installer Framework
下载地址:http://download.qt.io/official_releases/qt-installer-framework/
搜集依赖
- 使用Release模式构建项目
- 在release目录下删掉不必要的文件
- 运行windeployqt.exe命令
复制代码
1[windeployqt.exe路径] --release --qml --qmldir [qml源码路径] [exe文件路径]
如在我的环境下是
复制代码
1D:QtQt5.11.05.11.0mingw53_32binwindeployqt.exe --release --qml --qmldir D:srcqmlhuorong huorong.exe
- 手动拷贝其他的dll
我使用的是mingw53_32,需要拷贝以下文件
libgcc_s_dw2-1.dll libstdc++-6.dll libwinpthread-1.dll
创建安装包
- 将上面搜集的依赖拷贝到
installerpackagescn.net.pikachu.huorongdata
文件夹下 - 运行binarycreator.exe命令
复制代码
1[binarycreator.exe路径] -c [config.xml路径] -p [packages路径] [生成的安装程序exe文件名] -v
- 1
如在我的环境下是
复制代码
1D:QtQtIFW-3.0.4binbinarycreator.exe -c installer/config/config.xml -p installer/packages huorong_install.exe -v
- 1
最后的演示效果
思考与总结
如果Qt提供一键生成安装包就好了,何必这么麻烦呢?应该可以把这些操作用脚本写好,然后集成到QtCreator中。
附:
配置文件
config.xml
复制代码
1
2
3
4
5
6
7
8
9
10
11<?xml version="1.0" encoding="UTF-8"?> <Installer> <Name>火绒安全软件</Name> <Version>0.1.0</Version> <Title>火绒安全软件</Title> <Publisher>大黄老鼠</Publisher> <!-- Directory name is used in component.xml --> <StartMenuDir>pikachu</StartMenuDir> <TargetDir>@HomeDir@/pikachu/huorong</TargetDir> </Installer>
package.xml
复制代码
1
2
3
4
5
6
7
8
9
10
11<?xml version="1.0" encoding="UTF-8"?> <Package> <DisplayName>火绒安全软件</DisplayName> <Description>可执行文件</Description> <Version>0.1.0-1</Version> <ReleaseDate>2018-07-01</ReleaseDate> <Default>true</Default> <Script>installscript.qs</Script> <ForcedInstallation>true</ForcedInstallation> </Package>
installscript.qs
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43/**************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the FOO module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3 as published by the Free Software ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ function Component() { // default constructor } Component.prototype.createOperations = function() { // call default implementation to actually install README.txt! component.createOperations(); if (systemInfo.productType === "windows") { component.addOperation("CreateShortcut", "@TargetDir@/huorong.exe", "@StartMenuDir@/火绒安全软件.lnk", "workingDirectory=@TargetDir@", "iconPath=%SystemRoot%/system32/SHELL32.dll", "iconId=2", "description=Open README file"); component.addOperation("CreateShortcut", "@TargetDir@/huorong.exe", "@HomeDir@/Desktop/火绒安全软件.lnk"); component.addOperation("CreateShortcut", "@TargetDir@/maintenancetool.exe", "@StartMenuDir@/更新或卸载 火绒安全软件.lnk"); } }
最后
以上就是轻松期待最近收集整理的关于使用Qt Installer Framework制作安装包附:的全部内容,更多相关使用Qt内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复