Qt in Windows Docker container



  • Hi,

    I'm developing a Qt application on Windows. Currently I'm trying to automate the build process.
    I wanted to try using Docker containrs, to have a reliable build environment. However, I'm stuck at creating an image that contains a Qt installation. I have a Windows image that contains the msvc2017 toolchain but I don't know how to install Qt into the image in a non-interactive fashion.

    Is there a way to install Qt on Windows without a graphical installer? I tried the offline installer and a script but was unsuccessful.

    Regards
    Felix


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What script are you using ?



  • I used the script I found on StackOverflow and tried to modify it based on the documentation and the commets in this bug report.

    function Controller() {
        //gui.setSilent(true);
    	
        //installer.autoRejectMessageBoxes();
        installer.installationFinished.connect(function() {
            gui.clickButton(buttons.NextButton);
        })
    }
    
    Controller.prototype.WelcomePageCallback = function() {
        gui.clickButton(buttons.NextButton);
    }
    
    Controller.prototype.IntroductionPageCallback = function() {
        gui.clickButton(buttons.NextButton);
    }
    
    Controller.prototype.CredentialsPageCallback = function() {
        gui.clickButton(buttons.SkipButton);
    }
    
    Controller.prototype.TargetDirectoryPageCallback = function()
    {
        gui.currentPageWidget().TargetDirectoryLineEdit.setText("C:/Qt");
        gui.clickButton(buttons.NextButton);
    }
    
    Controller.prototype.ComponentSelectionPageCallback = function() {
        var widget = gui.currentPageWidget();
    
        widget.deselectAll();
    	widget.selectComponent("qt.595.win64_msvc2017_64");
    	widget.selectComponent("qt.595.qtcharts.win64_msvc2017_64");
    	
        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);
    }
    

    The installer opens but nothing happens. Furthermore, I can click buttons but only jump between the first two pages of the installer.

    I called the installer like this C:\Users\mrf\qt-opensource-windows-x86-5.9.5.exe --verbose --script .\qt-noninteractive.qs.



  • @Felix-Maurer Hi, were you able to create QT docker container?



  • I also tried but no luck. Below is the dockerfile and qt-installer-non-interactive.qs.
    I get this Network error: [ QNetworkReply::NetworkError(UnknownNetworkError) ] "Failed to connect to server. Check your network connection and try again."

    function Controller() {
        installer.autoRejectMessageBoxes();
        installer.installationFinished.connect(function() {
            gui.clickButton(buttons.NextButton);
        })
    }
    
    Controller.prototype.WelcomePageCallback = function() {
        gui.clickButton(buttons.NextButton, 3000);
    }
    
    Controller.prototype.CredentialsPageCallback = function() {
        gui.clickButton(buttons.NextButton);
    }
    
    Controller.prototype.IntroductionPageCallback = function() {
        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();
    
        widget.deselectAll();
        //widget.selectComponent("qt.55.gcc_64");
        //widget.selectComponent("qt.55.qtquickcontrols");
    
        widget.selectComponent("qt.tools.qtcreator");
        widget.selectComponent("qt.tools.vcredist_msvc2015_x64");
        widget.selectComponent("qt.qt5.5101.win64_msvc2015_64");
        widget.deselectComponent("qt.tools.vcredist_msvc2015_x86");
        //widget.deselectComponent("qt.55.qtquick1");
        //widget.deselectComponent("qt.55.qtscript");
        //widget.deselectComponent("qt.55.qtwebengine");
        //widget.deselectComponent("qt.extras");
        widget.deselectComponent("qt.qt5.5101.doc");
        widget.deselectComponent("qt.qt5.5101.examples");
    
        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);
    }
    
    FROM microsoft/windowsservercore:10.0.14393.2189
    
    COPY ["./install", "C:/tmp/qt"]
    
    RUN ["C:\\tmp\\qt\\qt-opensource-windows-x86-5.10.1.exe", "--script C:\\tmp\\qt\\qt-installer-noninteractive.qs"]
    
    ENV PATH "$PATH:C:\Qt\Qt5.10.1"
    
    ENV PATH "$PATH:C:\Program Files (x86)\Microsoft Visual Studio 15.0\VC"
    
    CMD ["vcvarsall.bat", "x86_amd64"]
    


  • I haven't retried it yet but will again in some days.



  • Hi,

    this is the Docker setup we use to create QBS builds. Maybe that can be of help even though this is made for Linux.

    http://code.qt.io/cgit/qbs/qbs.git/tree/docker/stretch/Dockerfile





  • Very cool thanks! That did work for me. Now I just have to adjust it to our needs.



  • @Felix-Maurer if your issue is solved, please don't forget to mark your post as such. Thanks.



  • @mkalinow I tried the above script but it did not work due to network issues. Is it possible to create docker build without connecting to internet or download offline?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.