QT工程安装包创建流程

QT安装包建立

准备工具

安装完成后,添加环境变量

在这里插入图片描述

添加到Qt Creator帮助文档

打开 Qt Creator,选择【工具】–>【选项】–>【帮助】–>【文档】–>【添加】
选择Qt IFW安装目录doc下的ifw.qch文件。

创建安装包工程

创建工程目录

mkdir -p AidTool_Installer
mkdir -p AidTool_Installer/config
mkdir -p AidTool_Installer/packages
mkdir -p AidTool_Installer/packages/com.man.ifw
mkdir -p AidTool_Installer/packages/data
mkdir -p AidTool_Installer/packages/meta
.
├── AidTool_Installer
   ├── AidTool.exe
   ├── config
   │   └── config.xml
   └── packages
       └── com.man.ifw
           ├── data
           │   ├── AidTool.exe
           │   ├── D3Dcompiler_47.dll
           │   ├── Qt5Core.dll
           │   ├── Qt5Gui.dll
           │   ├── Qt5SerialPort.dll
           │   ├── Qt5Svg.dll
           │   ├── Qt5Widgets.dll
           │   ├── iconengines
           │   │   └── qsvgicon.dll
           │   ├── imageformats
           │   │   ├── qgif.dll
           │   │   ├── qicns.dll
           │   │   ├── qico.dll
           │   │   ├── qjpeg.dll
           │   │   ├── qsvg.dll
           │   │   ├── qtga.dll
           │   │   ├── qtiff.dll
           │   │   ├── qwbmp.dll
           │   │   └── qwebp.dll
           │   ├── libEGL.dll
           │   ├── libGLESV2.dll
           │   ├── libgcc_s_seh-1.dll
           │   ├── libstdc++-6.dll
           │   ├── libwinpthread-1.dll
           │   ├── opengl32sw.dll
           │   ├── platforms
           │   │   └── qwindows.dll
           │   ├── startmenu
           │   │   ├── README
           │   │   ├── config
           │   │   │   └── config.xml
           │   │   ├── packages
           │   │   │   └── org.qtproject.ifw.example
           │   │   │       ├── data
           │   │   │       │   └── README.txt
           │   │   │       └── meta
           │   │   │           ├── installscript.qs
           │   │   │           └── package.xml
           │   │   ├── startmenu.pro
           │   │   └── startmenu.pro.user
           │   ├── styles
           │   │   └── qwindowsvistastyle.dll
           │   └── translations
           │       ├── qt_ar.qm
           │       ├── qt_bg.qm
           │       ├── qt_ca.qm
           │       ├── qt_cs.qm
           │       ├── qt_da.qm
           │       ├── qt_de.qm
           │       ├── qt_en.qm
           │       ├── qt_es.qm
           │       ├── qt_fi.qm
           │       ├── qt_fr.qm
           │       ├── qt_gd.qm
           │       ├── qt_he.qm
           │       ├── qt_hu.qm
           │       ├── qt_it.qm
           │       ├── qt_ja.qm
           │       ├── qt_ko.qm
           │       ├── qt_lv.qm
           │       ├── qt_pl.qm
           │       ├── qt_ru.qm
           │       ├── qt_sk.qm
           │       ├── qt_uk.qm
           │       └── qt_zh_TW.qm
           └── meta
               ├── installscript.qs
               └── package.xml

创建配置文件

在config目录下创建名为config.xml的文件,文件内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<Installer>
  <Name>AidTool Installer</Name>
  <Version>1.0.0</Version>
  <Title>AidTool Installer</Title>
  <Publisher>man</Publisher>
  <StartMenuDir>AidTool</StartMenuDir>
  <TargetDir>@HomeDir@/AidTool</TargetDir>
</Installer>

配置文件指定了安装界面上显示的如下信息:

  • < Title > 标题栏上安装程序名称
  • < Name > 显示在安装页面上应用程序的名称
  • < Version > 应用程序的版本号
  • < Publisher > 软件发布者
  • < StartMenuDir > 添加到开始菜单默认程序组名称
  • < TargetDir > 应用程序的安装目录

创建包信息文件

packages目录下com.man.ifw/meta目录下,package.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<Package>
    <DisplayName>AidTool</DisplayName>
    <Description>Aid Device Tool</Description>
    <Version>1.0.0-1</Version>
    <ReleaseDate>2020-12-29</ReleaseDate>
    <Default>true</Default>
    <Script>installscript.qs</Script>
    <Licenses>
        <License name="Beer Public License Agreement" file="license.txt" />
    </Licenses>
 </Package>

各个元素分别表示如下含义:

  • < DisplayName > 指定组件的名称
  • < Description > 显示选中组件的描述信息
  • < Version > 组件的版本号信息,可用作后期版本更新
  • < ReleaseDate > 组件发布的日期
  • < Default > 安装过程中组件是否默认选中,true表示默认选中,false默认补选中。
  • < Script > JavaScript文件名,执行一些个性化的安装操作
  • < Licenses > 添加许可文件,如果没有可以删除此段
license.txt文件创建

在这里插入图片描述

创建脚本文件

packages目录下com.man.ifw/meta目录下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()
{
    gui.pageWidgetByObjectName("LicenseAgreementPage").entered.connect(changeLicenseLabels);
}


changeLicenseLabels = function()
{
    page = gui.pageWidgetByObjectName("LicenseAgreementPage");
    page.AcceptLicenseLabel.setText("Yes I do!");
    page.RejectLicenseLabel.setText("No I don't!");
}


Component.prototype.createOperations = function()
{
    //调用默认实现
    component.createOperations();
    
    if (systemInfo.productType === "windows") {
    	//添加桌面快捷方式
        component.addOperation("CreateShortcut",
                            "@TargetDir@/AidTool.exe",
                            "@DesktopDir@/AidTool.lnk",
                            "workingDirectory=@TargetDir@");

		//添加开始菜单快捷方式
        component.addOperation("CreateShortcut",
                            "@TargetDir@/AidTool.exe",
                            "@StartMenuDir@/AidTool.lnk",
                            "workingDirectory=@TargetDir@");
    }
}

准备库文件

打开Powershell工具

cd build生成的xxx.exe目录下
#复制xx.exe文件到data目录下
cp ./xxx.exe AidTool_Installer/packages/data
cd AidTool_Installer/packages/data
C:\Qt\Qt5.13.2\5.13.2\mingw73_64\bin\windeployqt.exe AidTool.exe
#windeployqt.exe 工具依据编译工程选择的工具链确定

在这里插入图片描述

生成安装包

cd AidTool_Installer
binarycreator.exe -c .\config\config.xml -p .\packages AidTool -v

在这里插入图片描述

快捷打开windeployqt.exe工具

找到qt提供的设置环境变量工具
在这里插入图片描述
找到它
在这里插入图片描述
可以看到这个批处理,设置了相关地址变量,到PATH

@echo off
echo Setting up environment for Qt usage...
set PATH=C:\Qt\Qt5.12.10\5.12.10\mingw73_64\bin;C:/Qt/Qt5.12.10/Tools/mingw730_64\bin;%PATH%
cd /D C:\Qt\Qt5.12.10\5.12.10\mingw73_64

下面拷贝这两个路径添加
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
这时右键powershell打开即可使用windeployqt.exe工具。

参考

其他方式 - 使用打包工具

工具下载地址:https://enigmaprotector.com/cn/downloads.html

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

aron566

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值