Qt 安装程序框架:从卸载程序中删除单选按钮 [英] Qt installer framework: remove radio buttons from uninstaller

查看:22
本文介绍了Qt 安装程序框架:从卸载程序中删除单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我们的产品创建了一个简单的安装程序,只有 1 个组件,没有远程存储库管理器.

I have created a simple installer for our product with only 1 component and no remote repositories manager.

当我启动卸载程序时,介绍页面会显示 3 个单选按钮:

When I start the uninstaller, the introduction page shows 3 radio buttons:

  • 包管理器

  • Package manager

更新组件

删除所有组件

我只需要第三个,所以我检查了这个文档:

I need only the third one, so I checked this documentation:

http://doc-snapshot.qt-project.org/qtifw-master/noninteractive.html

据我所知,无法隐藏按钮,我将其添加到我的 install.qs 文件中:

As I have understood and being unable to hide the buttons, I added this to my install.qs file:

function Controller()
{
}

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

这应该会在介绍页面上自动点击下一步,所以它应该直接进入卸载页面.

This should auto-click Next on the introduction page so it should go directly to the uninstall page.

没有任何反应,无论我在 Controller 函数中写什么,介绍页面都会显示 3 个单选按钮.我在函数中添加了一些消息框,但它们从未被调用过.

Nothing happens, what ever I write in the Controller functions, the introduction page shows the 3 radio buttons. I added some messagebox in the function and they are never called.

有人知道怎么解决吗?

推荐答案

我想我有 2 个可行的解决方案.

I think I have 2 working solutions.

您需要像之前创建的那样创建一个 Controller:

You need to create a Controller like the one you started before:

function Controller() {
    if (installer.isUninstaller()) {
        installer.setDefaultPageVisible(QInstaller.Introduction, false);
        installer.setDefaultPageVisible(QInstaller.ComponentSelection, false);
        installer.setDefaultPageVisible(QInstaller.LicenseCheck, false);
    }
}

这将禁用经典安装/卸载工作流程中的所有页面.请务必检查您是否处于卸载模式.

This will disable all pages in the classic install/uninstall workflow. Make sure to check you're in uninstall mode.

function Controller()
{

}

Controller.prototype.IntroductionPageCallback = function()
{
    if (installer.isUninstaller()) {
        // Get the current wizard page
        var widget = gui.currentPageWidget(); 
        if (widget != null) {
            // Don't show buttons because we just want to uninstall the software
            widget.findChild("PackageManagerRadioButton").visible = false;
            widget.findChild("UpdaterRadioButton").visible = false;
            widget.findChild("UninstallerRadioButton").visible = false;
        }
    }
}

奖金

在安装程序模式下,默认选择我接受"许可协议.说真的,谁不呢?

Bonus

In installer mode, select by default "I accept" the Licence Agreement. Seriously, who doesn't?

Controller.prototype.LicenseAgreementPageCallback = function()
{
    var widget = gui.currentPageWidget();
    if (widget != null) {
        widget.AcceptLicenseRadioButton.checked = true;
    }
}

这篇关于Qt 安装程序框架:从卸载程序中删除单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆