Qt installer framework: remove radio buttons from uninstaller

橙三吉。 提交于 2019-11-29 19:14:20

问题


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

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

  • Package manager

  • Update components

  • Remove all components

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

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

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.

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.

Somebody knows how to solve it ?


回答1:


I think I have 2 working solutions.

First solution, if you want to have a single page uninstaller:

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.

If you want a 2 pages uninstaller:

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;
    }
}


来源:https://stackoverflow.com/questions/27290010/qt-installer-framework-remove-radio-buttons-from-uninstaller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!