qtqt5qt-installer

Qt installer scripting API: Can't select latest Qt version in online installer


A recent update to the metadata pulled by the Qt online installer has made some significant changes which have broken my installation script for Windows CI/CD.

I've solved one issue (bypassing the statistics collection screen - see DynamicTelemetryPluginFormCallback below), but I'm having trouble with another issue. On the "Select Components" screen, the default selected package category is now just LTS, and there doesn't seem to be a way to change it from the script. This means I can't install the latest Qt version, Qt 5.13.1. I can't use 5.12, since it doesn't have the Qt Controls 2 SplitView, which I am using in my application. Here's my current installer script, partially sourced from this answer. It worked fine before October 8, 2019:

function Controller() {
    installer.autoRejectMessageBoxes();
    installer.setMessageBoxAutomaticAnswer("installationErrorWithRetry", QMessageBox.Ignore);
    installer.setMessageBoxAutomaticAnswer("installationError", QMessageBox.Ignore);
    installer.installationFinished.connect(function() {
        gui.clickButton(buttons.NextButton);
    });
}

Controller.prototype.WelcomePageCallback = function() {
    // click delay here because the next button is initially disabled for ~1 second
    gui.clickButton(buttons.NextButton, 10000);
}

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

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

Controller.prototype.DynamicTelemetryPluginFormCallback = function() {
    var widget = gui.currentPageWidget();
    widget.TelemetryPluginForm.statisticGroupBox.disableStatisticRadioButton.checked = true;
    gui.clickButton(buttons.NextButton);
}

Controller.prototype.TargetDirectoryPageCallback = function() {
    gui.currentPageWidget().TargetDirectoryLineEdit.setText("C:\\Qt");
    gui.clickButton(buttons.NextButton);
}

Controller.prototype.ComponentSelectionPageCallback = function() {
    var widget = gui.currentPageWidget();

    console.log(JSON.stringify(widget));

    widget.ComponentsTreeView.

    widget.deselectAll();
    widget.selectComponent("qt.qt5.5131.win64_mingw73");
    widget.selectComponent("qt.tools.win64_mingw730");

    gui.clickButton(buttons.NextButton);
}

Controller.prototype.LicenseAgreementPageCallback = function() {
    gui.currentPageWidget().AcceptLicenseRadioButton.setChecked(true);
    gui.clickButton(buttons.NextButton);
}

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

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

Controller.prototype.FinishedPageCallback = function() {
    var checkBoxForm = gui.currentPageWidget().LaunchQtCreatorCheckBoxForm;
    if (checkBoxForm && checkBoxForm.launchQtCreatorCheckBox) {
        checkBoxForm.launchQtCreatorCheckBox.checked = false;
    }
    gui.clickButton(buttons.FinishButton);
}

I'm running the script with <path to installer>.exe --script <path to installer script>.qs --verbose

Running the online installer with this install script doesn't cause any errors, but it just doesn't install qt.qt5.5131.win64_mingw73.


Solution

  • I found an example on Github that takes care of my issue. My ComponentSelectionPageCallback now looks like this:

    Controller.prototype.ComponentSelectionPageCallback = function() {
        var page = gui.pageWidgetByObjectName("ComponentSelectionPage");
    
        var checkBox = gui.findChild(page, "Latest releases");
        var fetchButton = gui.findChild(page, "FetchCategoryButton");
    
        checkBox.click();
        fetchButton.click();
    
        var widget = gui.currentPageWidget();
    
        widget.deselectAll();
        widget.selectComponent("qt.qt5.5131.win64_mingw73");
        widget.selectComponent("qt.tools.win64_mingw730");
    
        gui.clickButton(buttons.NextButton);
    }
    

    See this file on Github for a complete example.