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
621

被折叠的 条评论
为什么被折叠?



