Qt Installer Framework自定义安装程序

Qt Installer Framework使用教程: 步骤一: 下载并安装Qt Installer Framework工具 http://download.qt.io/official_releases/qt-installer-framework/ 将安装目录添加到环境变量,如安装D盘时D:\Qt\QtIFW-4.5.0\bin 步骤二: 将测试例子(如D:\Qt\QtIFW-4.5.0\examples\tutorial)拷贝到某一目录如:D:\Qt\test confi 阅读详情
AI摘要

本文介绍了使用脚本自定义Qt Installer Framework安装程序的方法,包括添加操作、页面、widget,与安装程序功能交互,翻译页面以及配置和覆盖默认翻译等。可使用组件脚本和控制脚本,还能通过特定函数和方法实现各种自定义操作。

Customizing Installers

自定义安装程序

You can use scripting to customize installers by:

可以使用脚本通过以下方式自定义安装程序:

  • Adding Qt Installer Framework operations that are prepared by the scripts and performed by the installer.
  • 添加由脚本准备并由安装程序执行的Qt安装程序框架操作。
  • Adding new pages that you specify in the package.xml file and place in the packages directory.
  • 添加在package.xml文件中指定的新页面,并将其放置在packages目录中。
  • Modifying existing pages by inserting custom user interface elements into them as single widgets.
  • 通过将自定义用户界面元素作为单个widget插入现有页面来修改它们。
  • Adding language variants.
  • 添加语言变量。

You can use both component scripts and a control script to customize installers. A component script is associated with a particular component by specifying it in the Script element of the package.xml file of the component. The script is loaded when the component's metadata is fetched. For more information about component scripts, see Component Scripting.

​可以使用组件脚本和控制脚本来自定义安装程序。通过在组件的package.xml文件的Script元素中指定它,组件脚本与特定组件相关联。在获取组件的元数据时加载脚本。有关组件脚本的更多信息,请参阅组件脚本。

A control script is associated with the whole installer by specifying it in the ControlScript element of the config.xml file of the installer. Control scripts can be part of the installer resources or be passed on the command line. They can be used to modify the installer pages that are presented to users before components are loaded. Also, you can use them to modify pages in the uninstaller. For more information, see Controller Scripting.

​通过在安装程序的config.xml文件的ControlScript元素中指定控制脚本,控制脚本与整个安装程序相关联。控制脚本可以是安装程序资源的一部分,也可以在命令行上传递。它们可用于在加载组件之前修改呈现给用户的安装程序页面。此外,还可以使用它们来修改卸载程序中的页面。有关更多信息,请参阅控制器脚本。

For more information about the global JavaScript objects that can be used in component and control scripts, see Scripting API.

​有关可在组件和控制脚本中使用的全局JavaScript对象的更多信息,请参阅编写API脚本。

Adding Operations

添加操作

You can use component scripts to perform Qt Installer Framework operations during the installation process. Typically, operations manipulate files by moving, copying, or patching them. Use the QInstaller::Component::addOperation or QInstaller::Component::addElevatedOperation function to add operations. For more information, see Adding Operations to Components.

​可以在安装过程中使用组件脚本执行Qt Installer Framework操作。通常,操作通过移动、复制或修补文件来操纵文件。使用QInstaller::Component::addOperation或QInstaller:Component::addElevatedOperation函数添加操作。有关详细信息,请参见向组件添加操作。

In addition, you can implement methods to register custom installation operations in the installer by deriving KDUpdater::UpdateOperation. For more information, see Registering Custom Operations.

​此外,可以通过派生KDUpdater::UpdateOperation来实现在安装程序中注册自定义安装操作的方法。有关更多信息,请参阅注册自定义操作。

For a summary of available operations, see Operations.

​有关可用操作的摘要,请参阅操作。

Adding Pages

添加页面

A component can contain one or more user interface files, which are placed into the installer by a component or control script. The installer automatically loads all user interface files listed in the UserInterfaces element of the package.xml file.

一个组件可以包含一个或多个用户界面文件,这些文件由组件或控制脚本放置在安装程序中。安装程序会自动加载package.xml文件的UserInterfaces元素中列出的所有用户界面文件。

Using Component Scripts to Add Pages

使用组件脚本添加页面

To add a new page to the installer, use the installer::addWizardPage() method and specify the location of the new page. For example, the following code adds an instance of MyPage before the ready for installation page:

​要向安装程序添加新页面,请使用installer::addWizardPage()方法并指定新页面的位置。例如,以下代码在准备安装页面之前添加了MyPage的实例:

installer.addWizardPage( component, "MyPage", QInstaller.ReadyForInstallation );

You can use component scripts to access the loaded widgets by calling the component::userInterface() method with the class name of the widget, as illustrated by the following code snippet:

​可以使用组件脚本访问加载的widget,方法是使用widget的类名调用component::userInterface()方法,如以下代码片段所示:

component.userInterface( "MyPage" ).checkbox.checked = true;

You can also have a callback for the page that is added. To access it, use the object name set in the UI file (for example, "MyPage"). Then create the Dynamic${ObjectName}Callback function (for example, DynamicMyPageCallback):

还可以对添加的页面进行回调。要访问它,请使用UI文件中设置的对象名称(例如“MyPage”)。然后创建动态${ObjectName}Callback函数(例如,DynamicMyPageCallback):

Component.prototype.DynamicMyPageCallback = function()
{
    var page = gui.pageWidgetByObjectName("DynamicMyPage");
    page.myButton.click,
    page.myWidget.subWidget.setText("hello")
}

You can access widgets by using their object names that are set in the UI file. For example, myButton and myWidget are widget object names in the code above.

可以使用UI文件中设置的widget对象名称来访问它们。例如,myButton和myWidget是上面代码中的widget对象名称。

Adding Widgets

添加Widget

You can use component or control scripts to insert custom user interface elements into the installer as single widgets (such as a check box).

可以使用组件或控制脚本将自定义用户界面元素作为单个widget(如复选框)插入安装程序中。

To insert a single widget, use the installer::addWizardPageItem method. For example, the following code snippet adds an instance of MyWidget to the component selection page from within a script:

​要插入单个widget,请使用installer::addWizardPageItem方法。例如,以下代码片段将MyWidget的实例从脚本中添加到组件选择页面:

​installer.addWizardPageItem( component, "MyWidget", QInstaller.ComponentSelection );

Interacting with Installer Functionality

与安装程序功能交互

You can use control scripts to execute installer functions automatically in tests, for example. The following snippet illustrates how to automatically click the Next button on the target directory selection page:

例如,可以使用控制脚本在测试中自动执行安装程序函数。以下代码段说明了如何在目标目录选择页面上自动单击“下一步”按钮:

Controller.prototype.TargetDirectoryPageCallback = function()
{
    gui.clickButton(buttons.NextButton);
}

Translating Pages

翻译页面

The installer uses the Qt Translation system to support the translation of user-readable output to several languages. To provide end users with localized versions of strings contained in the component scripts and user interfaces, create QTranslator files that the installation system loads along with the component. The installer loads the translation file that matches the current system locale. For example, if the system locale is German, the de.qm file is loaded. In addition, a localized license_de.txt is shown instead of the default license.txt if it is found.

​安装程序使用Qt翻译系统支持将用户可读输出翻译成多种语言。为了向最终用户提供组件脚本和用户界面中包含的字符串的本地化版本,请创建安装系统随组件加载的QTranslator文件。安装程序加载与当前系统区域设置匹配的翻译文件。例如,如果系统区域设置为德语,则加载de.qm文件。此外,如果找到默认的license.txt,则显示本地化的license_de.txt,而不是默认的license.txt。

Translations need to be added to the package.xml file to be activated for a component:

需要将翻译添加到package.xml文件中,以便为组件激活:

<Translations>
    <Translation>de.qm</Translation>
</Translations>

Use the qsTranslate() function for literal text within scripts. Additionally, you can add the Component.prototype.retranslateUi method to the script. It is called when the language of the installer changes and the translation file is loaded.

对脚本中的文字文本使用qsTranslate()函数。此外,可以将Component.prototype.retranslateUi方法添加到脚本中。当安装程序的语言更改并且加载了翻译文件时,会调用它。

Note: The translation system can also be used to customize the UI. Use e.g. an en.ts file to replace any text in the installer with a custom English version.

注意:翻译系统也可用于自定义UI。例如,使用en.ts文件将安装程序中的任何文本替换为自定义英文版本。

Configuring and Overwriting Default Translations

配置和覆盖默认翻译

The installer has been localized into several languages. System language is used to define the loaded language. In case you want to define the used language for your installer, define the languages in config.xml using the <Translations> element. For example, using only German translations:

安装程序已本地化为多种语言。系统语言用于定义加载的语言。如果想为安装程序定义使用的语言,请使用<Translations>元素在config.xml中定义语言。例如,仅使用德语翻译:

<Translations>
    <Translation>ifw_de</Translation>
    <Translation>qt_de</Translation>
</Translations>

The default translations can be also overwritten. Write your own translation file and add it to a custom resource called :/translations_new. This custom resource can be added to the installer using binarycreator option -r. For more information, see Summary of binarycreator Parameters.

​默认翻译也可以被覆盖。编写自己的翻译文件并将其添加到名为:/translations_new的自定义资源中。可以使用binarycreator选项-r将此自定义资源添加到安装程序中。有关更多信息,请参阅binarycreatorParameters摘要。

If the translated language is not already part of the existing translations of Qt Installer Framework, you need to also include the Qt Base translation for that language in the resource file. For this you need to point to the qtbase_*.qm for your language from the location of QT_INSTALL_TRANSLATIONS and alias it in the resource file.

如果翻译的语言还不是Qt Installer Framework现有翻译的一部分,还需要在资源文件中包含该语言的Qt Base翻译。为此,需要从QT_INSTALL_TRANLATIONS的位置指向您的语言的qtbase_*.qm,并在资源文件中将其别名。

For example, for the Czech translation a custom translations_new.qrc should look like this:

例如,对于捷克语翻译,自定义translations_new.qrc应该如下所示:

<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/translations_new">
    <file>ifw_cs.qm</file>
    <file alias="qt_cs.qm">%QT_INSTALL_TRANSLATIONS%/qtbase_cs.qm</file>
</qresource>
</RCC>

The path for replacing QT_INSTALL_TRANSLATIONS can be retrieved from the output of qmake -query of your Qt installation.

替换QT_INSTALL_TRANLATIONS的路径可以从QT安装的qmake-query的输出中检索。

Promoting UpdatesQt Installer Framework Examples

© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. The Qt Company, Qt and their respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

别只用来装Qt!深入聊聊MaintenanceTool.exe和Qt Installer Framework的‘前世今生’与高级玩法 本文深入探讨了MaintenanceTool.exe与Qt Installer Framework的技术架构和高级应用,揭示了其超越Qt组件管理的强大功能。通过解析仓库配置、组件管理机制和脚本控制,展示了如何利用该框架构建专业级应用程序安装程序,并介绍了Qt Script在现代Qt开发中的定位与替代方案。 阅读详情

相关推荐

Qt应用发布进阶:用Installer Framework给你的软件加上多组件选择和自定义UI皮肤

本文深入探讨了如何使用Qt Installer Framework为Qt应用打造专业级安装体验,包括模块化安装系统设计、自定义UI皮肤和高级安装流程控制。通过详细的代码示例和配置说明,帮助开发者实现多组件选择、品牌化界面和智能安装逻辑,显著提升软件发布质量。

weixin_29234509的博客 361

qt几种常见安装包制作工具-Qt Installer Framework

QtIFW提供了一组工具和实用程序,可以一次性创建安装程序,并在所有支持的桌面Qt平台上部署它们,而无需重写源代码。

bmseven的博客 3908

Qt基础之四十:Qt Installer Framework(QtIFW)的编译、使用和实现原理

Qt Installer Framework(QtIFW)的编译、使用和实现原理

草上爬的博客 6991

Qt 使用Installer Framework制作安装包

Qt Installer Framework (安装程序框架)是一个强大的工具集,用于创建自定义的在线和离线安装程序。它具有高度可配置性和可自定义性,适用于所有支持的Qt平台:Linux、Windows和macOS。并且其提供了清晰的文档和示例,帮助开发人员为应用程序创建安装程序。 - 本文以Windows为例,简述其制作一个软件安装包的步骤。

做减求空 4953

使用Qt Installer Framework(IFW)创建安装程序

在本例中,我们用Qt Installer Framework创建了一个简单的安装程序,其中包含了一个欢迎页面、一个许可协议页面、一个选择安装位置的页面和一个完成页面。在这个安装程序中,我们想要有一个简单的欢迎页面,一个许可协议页面,一个选择安装位置的页面和一个完成页面。通过IFW,开发人员可以轻松地为他们的Qt应用程序创建专业的跨平台安装程序,并且可以在Windows,Linux和MacOS等操作系统上运行。在本例中,我们将创建四个UI文件,分别为欢迎页面,许可协议页面,安装位置选择页面和完成页面。

CyberLynxX的博客 495

构建自定义的 Qt 安装程序

然后,我们覆盖了 performInstallation() 方法,并在其中执行自己的安装逻辑。这个框架提供了一个强大的、灵活的方式来构建自定义的安装程序,同时可以轻松地集成到我们的 Qt 项目中。最后,我们需要将所有的组件组合起来,生成我们的自定义安装程序。通过一个好的安装程序,可以方便用户快速地安装和使用软件,并为软件赢得更多的用户。在此基础上,我们需要添加一些额外的工具和组件来构建我们的安装程序。这将使得 Qt 安装器框架成为我们的 Qt 项目的一部分,并使得我们能够使用其中的函数和类。

TechRoarX的博客 376

Qt Installer Framework翻译(5-4)

自定义安装程序 您可以使用脚本通过以下方式来自定义安装程序: > 添加Qt Installer Framework操作,该操作由脚本提供,并由安装程序执行。 > 添加新页面,该页面由您在package.xml文件中指定,并将其放置在packages文件夹中。 > 修改现有页面,通过插入自定义用户界面元素来作为子部件。 > 添加语言变体。 您可以同时使用组件脚本和控制脚...

java梦工厂 422

打造漂亮的 Qt IFW 安装程序

然后,我们需要定义安装程序的界面和逻辑。在 “meta” 文件夹中,打开 “installer.xml” 文件,可以看到一个 XML 文件,定义了安装程序的各个界面和逻辑步骤。在这里,我们可以通过设置 “Default” 风格的 CSS 样式表,来改变安装程序界面的外观,让其更加美观。当然,在实际应用中,我们还可以添加一些自定义的逻辑和交互界面,让用户的体验更加友好和便捷。其中,“-c” 参数指定了配置文件,“-p” 参数指定了软件包文件夹,“installer.exe” 是生成的安装程序文件名。

James_CODER的博客 832

QT安装程序制作

转自 http://blog.csdn.net/hutusoft/article/details/79060567 1 安装Qt installerframework 从QT官网的http://download.qt.io/official_releases/qt-installer-framework/下载qt installer framework安装程序进行安装。 2 配置安

skykingf的专栏 622

【Qt】Qt Installer Framework 中 config.xml 文件详解

通过修改这些配置,可以自定义安装程序的名称、版本号、标题、发布者、安装目标路径等信息,并指定安装完成后要运行的程序、添加Logo、水印等自定义图像,以及指定远程仓库的信息等。这只是一个示例配置文件,实际使用时需要根据您的应用程序的要求进行相应的修改和扩展。通过修改这些配置,您可以自定义安装程序的名称、版本号、标题、发布者以及安装目标路径等信息。:指定在开始菜单中创建的文件夹或链接的名称。:指定在开始菜单中创建的文件夹或链接的名称。:指定应用程序的安装目标路径。:指定要运行的程序的描述信息。

Fanjufei的博客 285

使用 Qt IFW 制作自己的在线安装程序

在使用 Qt Creator 的情况下,可以在“帮助”菜单中找到“安装外观和工具”,然后选择“Qt Installer Framework”进行安装。在 Qt IFW 的帮助下,我们可以轻松创建自己的在线安装程序,并根据需要定制不同的组件和安装选项。在 Qt Creator 的菜单栏中选择“构建”,然后选择“构建解决方案”或者“构建独立的安装程序”。在 Qt Creator 的菜单栏中选择“项目”,然后选择“添加新文件”,并选择“Qt Installer Framework”模板。

HackLogic的博客 320

Qt-Installer-Framework使用二

Qt-Installer-Framework使用二 上一篇文章记录了QIFW基本的使用,下面说说一些个性化配置功能. 打包结构说明 基本结构如下所示: 主要包含两部分,config 和 packages. config 目录主要放置一些打包软件的整体配置,比如打包后安装过程中显示的软件名称、版本号、公司名称、界面图标等等信息; packages 目录主要配置每个安装组件的信息。组件化安装配置是 ...

1+1=10 个人博客http://kevinlq.com/ 794

使用Qt IFW创建自定义的在线安装程序

Qt Installer Framework(IFW)是一个强大的工具,可以帮助开发人员创建定制化的安装程序。例如,Name元素指定安装程序的名称,Version元素指定版本号,Title元素指定安装程序的标题,Publisher元素指定发布者等。通过使用Qt IFW,您可以轻松创建定制化的在线安装程序。本文介绍了创建安装程序的基本步骤,并提供了相应的源代码示例。安装程序的配置文件是一个XML文件,用于指定安装程序的设置和行为。按照安装向导的指示进行操作,并确保安装过程中的操作和行为与您的预期一致。

UhxzCombined的博客 314

开源项目Qt Installer Framework快速指南与常见问题解答

开源项目Qt Installer Framework快速指南与常见问题解答 项目基础介绍 项目名称: Qt Installer Framework 主要编程语言: C++, 辅以Python, Qt Script, QMake等 项目地址: https://github.com/qtproject/installer-framework.git Qt Installer Framework是由Qt...

gitblog_00497的博客 966

QT Installer Framework 从入门到打包实战

随着软件开发的不断演进,应用的分发与安装变得越来越重要。QT Installer Framework正是在这样的背景下应运而生,它是一个用于创建跨平台安装程序的开源框架,专为解决软件部署的复杂性问题而设计。本章将介绍QT Installer Framework的基本概念、特点以及如何利用它来简化安装包的生成过程。QT Installer Framework是一个基于Qt开发的工具集,它允许开发者为自己的应用程序创建专业的安装包。

weixin_42515392的博客 1812

VSAN数据救援实战:当26个虚拟机突然不可访问时我们做了什么?

本文深度复盘了一次由运维操作失误引发的VMware vSAN存储危机,导致26个虚拟机数据不可访问的实战救援过程。文章详细剖析了vSAN脑裂状态的诊断方法,分享了在官方支持受限时,如何结合社区智慧与自主分析,通过精准的底层命令干预和状态推理,最终成功恢复全部数据的破局思路与操作细节,为vSAN数据救援提供了宝贵经验。

weixin_35749786的博客 241

Qt Installer Framework从命令行使用

要创建包含联机存储库中选定组件集的个人脱机安装程序,请使用create-offline命令。对于同一安装内容将被多次部署或部署在多台机器上的场景,这是一个有用的功能,因为它节省了下载组件存档的时间,并使安装易于复制。--offline-installer-name选项可用于为生成的脱机安装程序设置所需的名称。请注意,只能从启用了有效存储库的联机安装程序创建脱机安装程序。

aggs1990的专栏 342

Codex本地部署指南:从环境配置到API集成实战

Codex作为OpenAI推出的代码生成模型,能够根据自然语言描述自动生成代码片段,大幅提升开发效率。这次我们重点分析Codex的本地部署方案、硬件门槛、接口调用方式和实际使用效果,帮助开发者判断是否值得投入时间部署。 从技术架构看,Codex基于GPT-3模型微调,专门针对代码生成任务优化。最新版本支持多种编程语言,包括Python、JavaScript、Java、C++等主流语言。对于国内开发者来说,最关心的是能否在本地环境稳定运行,以及是否需要特殊网络配置。 1. 核心能力速览 能力项 技术说明 模型

weixin_33309048的博客 534

Qt Installer Framework修改提取安装程序示例

使用组件脚本中的提取存档挂钩修改目标路径。Modify Extract Installer演示了如何覆盖component.createOperationsForArchive()函数,以便能够将组件安装到修改后的路径。

aggs1990的专栏 931

QT5.14.2+VS2019安装配置教程Windows

QT5.14.2+VS2019安装使用教程Windows前言一. QT的下载与安装1. QT的下载2. QT的安装二. 配置Visual Studio编译器环境1. 扩展工具下载2. 扩展工具配置 前言 由于Visual Studio 的功能强大,很多开发人员比较熟悉使用,所以可以通过将QT配置到Visual Studio中进行开发。 一. QT的下载与安装 1. QT的下载 QT5.14.2下载地址 2. QT的安装 断开网络!断开网络!!断开网络!!! 安装QT之前,需要断开电脑的网络连接,这样就

Zander0的博客 7257

数学文化赏析MOOC笔记【2023】

深圳大学UOOC课程《数学文化赏析》课程笔记

simplenthpower的博客 1754
上一篇: Qt Installer Framework创建在线安装程序
下一篇: Qt Installer Framework更改安装程序UI示例
꧁白杨树下꧂
博客等级 码龄15年 1019粉丝 209原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

打赏作者

꧁白杨树下꧂

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

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

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

打赏作者

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

抵扣说明:

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

余额充值
⌂ 换网址