使用QtInstallerFramework制作安装向导

「C++ 40 周年」主题征文大赛(有机会与C++之父现场交流!) 10w+人浏览 726人参与

1.QtIFW-4.6.1制作安装向导程序版本选择
//生成的向导程序可以在win7、win10运行
QtInstallerFramework-windows-x64-4.6.1.exe
//生成的向导程序可以在win10运行,在win7运行不了
QtInstallerFramework-windows-x64-4.8.1.exe
2.create_installer.bat是创建向导程序脚本。需要修改的配置文件有:config.xml、package.xml、installscript.qs。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
core文件夹名称可以随便修改
在这里插入图片描述
data目录下放要打包的程序,最好不要直接把exe、dll放到data文件夹下,因为那样程序安装后会和一些安装卸载脚本混在一起。单独放在一个文件夹下,例如我这里打包的程序文件夹VTKDemo_bin,VTKDemo_bin里面包含exe和dll文件。
在这里插入图片描述
关键字解释查看:
https://blog.youkuaiyun.com/kenfan1647/article/details/119905106

3.所有配置文件的内容
config.xml内容:

<?xml version="1.0" encoding="UTF-8"?>
<Installer>
    <Name>VTKDemo软件</Name>
    <Version>1.2.3</Version>
    <Title>VTKDemo软件</Title>
    <Publisher>MST</Publisher>
    <!-- Directory name is used in component.xml -->
    <StartMenuDir>VTKDemo</StartMenuDir>
    <TargetDir>@HomeDir@/VTKDemo_bin</TargetDir>
    <WizardDefaultWidth>800</WizardDefaultWidth>
    <WizardDefaultHeight>600</WizardDefaultHeight>
</Installer>

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",
                      "@TargetDir@/VTKDemo_bin/VTKDemo.exe",
                      "@StartMenuDir@/VTKDemo.lnk",
                      "workingDirectory=@TargetDir@");

        // 创建桌面快捷方式 (可选)
        component.addOperation(
                      "CreateShortcut",
                      "@TargetDir@/VTKDemo_bin/VTKDemo.exe",
                      "@DesktopDir@/VTKDemo.lnk",
                      "workingDirectory=@TargetDir@");
    }
}

package.xml内容:

<?xml version="1.0" encoding="UTF-8"?>
<Package>
    <DisplayName>VTKDemo主程序</DisplayName>
    <Description>VTKDemo, accessible through a start menu entry.</Description>
    <Version>1.2.3</Version>
    <ReleaseDate>2025-11-24</ReleaseDate>
    <Default>true</Default>
    <Script>installscript.qs</Script>
</Package>

create_installer.bat是我写的一个脚本文件,双击运行开始制作安装向导,内容如下:

"E:/Program Files/QtIFW-4.6.1/bin/binarycreator.exe" -c config/config.xml -p packages VTKDemoInstaller.exe -v
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值