[Development] Qt Installer Framework Script

Karsten Heimrich karsten.heimrich at digia.com
Fri Apr 10 12:50:43 CEST 2015


Hi,

On 09.04.2015 18:50, Berkay Elbir wrote:
>
> Hello,
>
> I have a question about QInstaller. 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.
>
> Should I write another script for Uninstaller? Actually, I managed to 
> come here with the examples. This is my script :
>

what you did is a so called Component script, which is executed during 
install, update, management but not uninstall. There's a second form of 
scripts available, called Control scripts that are executed always. You 
can either embed it into your application or start a IFW binary with 
--script path/to/script. In your case you would like to embed it inside 
the binary though.

Starting point here is the config.xml, put your script next to that file 
and add a <ControlScript>your_script</ControlScript> tag. See: 
http://doc.qt.io/qtinstallerframework/ifw-globalconfig.html

Now your script could look like this:

function Controller() { }

Controller.prototype.IntroductionPageCallback =function() {
if (installer.isUninstaller()) {
         if (installer.isProcessRunning(YOUR_PROCESS_NAME)) {
             var widget =gui.currentPageWidget(); // get the current 
wizard page
widget.ErrorLabel.setText("<font color='red'>" + ("Process: " + 
YOUR_PROCESS + " still running." + "</font>");

            // hide all following pages
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);
}
     }
}

Basically if you detect your process is running, print an error message 
and hide all pages. So if the user presses the 'Next' button he will end 
up on the finish page. Of course you need to connect to the 
|packageManagerCoreTypeChanged() |signal the page emits so you can set 
the pages visible again if the user switches to package manager or 
updater mode. See: 
http://doc.qt.io/qtinstallerframework/noninteractive.html#introduction-page 
there is an example script.

Regards,

--------
Karsten Heimrich, Senior Software Engineer | The Qt Company

Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B

Email: karsten.heimrich at theqtcompany.com | www.qt.io |Qt Blog: http://blog.qt.digia.com/ | Twitter: @QtbyDigia, @Qtproject | Facebook: www.facebook.com/qt

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20150410/30b790d8/attachment.html>


More information about the Development mailing list