qt 安装包生成2

Posted jzlzn

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了qt 安装包生成2相关的知识,希望对你有一定的参考价值。

使用Qt Installer Framework制作安装包

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_32768743/article/details/80871697

步骤

制作安装包的步骤:

  • 去官网下载Qt Installer Framework的安装包并安装(已经安装的请跳过这步)
  • 使用windeployqt.exe集齐所需依赖
  • 使用binarycreator.exe创建安装包

具体操作流程:

安装Qt Installer Framework

下载地址:http://download.qt.io/official_releases/qt-installer-framework/

技术分享图片
技术分享图片
技术分享图片
技术分享图片

搜集依赖

  • 使用Release模式构建项目
    技术分享图片
    技术分享图片
  • 在release目录下删掉不必要的文件
    技术分享图片
  • 运行windeployqt.exe命令
[windeployqt.exe路径] --release --qml --qmldir [qml源码路径] [exe文件路径]
  • 1

技术分享图片

如在我的环境下是

D:QtQt5.11.05.11.0mingw53_32inwindeployqt.exe --release --qml --qmldir D:srcqmlhuorong huorong.exe
  • 1
  • 手动拷贝其他的dll

我使用的是mingw53_32,需要拷贝以下文件

libgcc_s_dw2-1.dll libstdc++-6.dll libwinpthread-1.dll

技术分享图片

创建安装包

  • 将上面搜集的依赖拷贝到installerpackagescn.net.pikachu.huorongdata文件夹下
    技术分享图片
  • 运行binarycreator.exe命令
[binarycreator.exe路径] -c [config.xml路径] -p [packages路径] [生成的安装程序exe文件名] -v
  • 1

技术分享图片

如在我的环境下是

D:QtQtIFW-3.0.4ininarycreator.exe -c installer/config/config.xml -p installer/packages huorong_install.exe -v
  • 1

最后的演示效果

技术分享图片

思考与总结

如果Qt提供一键生成安装包就好了,何必这么麻烦呢?应该可以把这些操作用脚本写好,然后集成到QtCreator中。

附:

配置文件

config.xml

<?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>@[email protected]/pikachu/huorong</TargetDir>
</Installer>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

package.xml

<?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>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

installscript.qs

/****************************************************************************
**
** 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", "@[email protected]/huorong.exe", "@[email protected]/火绒安全软件.lnk",
            "[email protected]@", "iconPath=%SystemRoot%/system32/SHELL32.dll",
            "iconId=2", "description=Open README file");
        component.addOperation("CreateShortcut", "@[email protected]/huorong.exe", "@[email protected]/Desktop/火绒安全软件.lnk");

        component.addOperation("CreateShortcut", "@[email protected]/maintenancetool.exe", "@[email protected]/更新或卸载 火绒安全软件.lnk");
    }







以上是关于qt 安装包生成2的主要内容,如果未能解决你的问题,请参考以下文章

在mac下,qt自动化打包、签名、dmg安装包生成、公证

qt creator源码全方面分析(2-0)

QT 实用代码片段

Qt5.14.2下载与安装(保姆级图文教程)

QT怎么安装到Linux上

26.Qt Quick QML-RotationAnimationPathAnimationSmoothedAnimationBehaviorPauseAnimationSequential(代码片段