installscript.js Example File | Qt Installer Framework Documentation 4.11.0

- Qt Installer Framework Documentation
- Component Error Example
- installscript.js Example File
- Qt Installer Framework 4.11.0

# installscript.js Example File

componenterror/packages/root/meta/installscript.js

     /* Copyright (C) 2026 The Qt Company Ltd.
      *
      * SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
     */

     function abortInstaller()
     {
         installer.setDefaultPageVisible(QInstaller.Introduction, false);
         installer.setDefaultPageVisible(QInstaller.TargetDirectory, false);
         installer.setDefaultPageVisible(QInstaller.ComponentSelection, false);
         installer.setDefaultPageVisible(QInstaller.ReadyForInstallation, false);
         installer.setDefaultPageVisible(QInstaller.StartMenuSelection, false);
         installer.setDefaultPageVisible(QInstaller.PerformInstallation, false);
         installer.setDefaultPageVisible(QInstaller.LicenseCheck, false);

         var abortText = "<font color='red' size=3>" + qsTr("Installation failed:") + "</font>";

         var error_list = installer.value("component_errors").split(";;;");
         abortText += "<ul>";
         // ignore the first empty one
         for (var i = 0; i < error_list.length; ++i) {
             if (error_list[i] !== "") {
                 console.log(error_list[i]);
                 abortText += "<li>" + error_list[i] + "</li>"
             }
         }
         abortText += "</ul>";
         installer.setValue("FinishedText", abortText);
     }

     function reactOnAbortInstallerChange()
     {
         if (installer.value("ComponentError") === "true")
             abortInstaller();
     }

     function Component()
     {
         installer.finishAllComponentsReset.connect(reactOnAbortInstallerChange);
     }