Nominate our 2022 Qt Champions!

QtScript in Qt Installer framework

  • Hello,

    I have a simple .ui file which contains checkbox object named "LogOut", the man frame is object named "LogOutCheckBoxForm". I add this to the QInstaller.InstallationFinished page. It is correctly added there, I can see it the at end of the installation. I want to log out the user from the computer (Mac OS X) when the checkbox is checked and the user clicks finish. But the problem is that when the user checks the checkbox and clicks the Finish button, nothing happens.

    I have following installscript.js

    @function Component(){
    component.loaded.connect(this, componentLoaded);
    installer.finishButtonClicked.connect(this, finishClicked);

    componentLoaded = function(){
    installer.addWizardPageItem(component, "LogOutCheckBoxForm", QInstaller.InstallationFinished);



    finishClicked = function(){

    if(installer.isInstaller() && installer.status == QInstaller.Success){
        var isLogOutChecked = component.userInterface("LogOutCheckBoxForm").LogOut.checked;
        if (isLogOutChecked) {
            installer.execute("osascript", new Array("-e \'tell application \"loginwindow\" to  «event aevtrlgo»\'"));


    @<?xml version="1.0" encoding="UTF-8"?>
    <DisplayName>Log out test/DisplayName>
    <Description>Log out test</Description>


    Ok, I've found out that problem is with the @installer.execute("osascript", new Array("-e 'tell application "loginwindow" to «event aevtrlgo»'"));@ part, because when I place there QDesktopServices.openUrl( it opens the web page.

    Am I calling it wrong? Is there any other way to call shell command from qtscript?

  • Hello,

    I want to ask another question to you. How can I make the Uninstaller check exe is running or not before uninstalling? I can do this with installing process but I can not write correct script (installscript.qs) for uninstalling process.

    This is my script. Or Should I write another script for Uninstaller?

    function cancelInstaller()
    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);

    installer.setValue("FinishedText", "Operation was canceled!");


    function Component()
    var programFiles = installer.environmentVariable("ProgramFiles");
    if (programFiles != "")
    installer.setValue("TargetDir", programFiles + "/A");

    var programValid = true;
    if(installer.isProcessRunning("A.exe") == true)
    	QMessageBox["warning"]("os.warning", "Installer","Program is currently running!",QMessageBox.Ok);
    	programValid = false;
    if (!programValid) {


    Component.prototype.isDefault = function()
    // select the component by default
    return true;

    Component.prototype.createOperations = function()
    try {
    // call the base create operations function
    if (installer.value("os") === "win") {
    component.addElevatedOperation("Execute", "{0,3010}", "@TargetDir@\vcredist\vcredist_x86.exe", "/norestart", "/q");
    component.addOperation("CreateShortcut", "@TargetDir@/A.exe", "@StartMenuDir@/A.lnk");
    component.addOperation("CreateShortcut", "@TargetDir@/uninstall.exe", "@StartMenuDir@/Uninstall.lnk");
    component.addOperation("CreateShortcut", "@TargetDir@/A.exe", "@DesktopDir@/A.lnk");
    } catch (e) {

Log in to reply