What Qt installer framework is ?
Qt installer framework is a collection of tools that can be used to make installers on Linux, Windows and Mac . You can either use pre-built versions or compile it from source.
There are other softwares like NSIS, installBuilder that can be used to make installers but I wanted an open source & cross platform tool therefore I chose Qt installer framework and it’s also fun to try out new things.
How to use it ?
Qt installer framework needs to be provided with a certain directory structure. The image below shows how the directory structure should be
The config folder is where we put things that define the configuration of the installer. That is, what information should be displayed when the installer starts, where on user’s system the application should be installed by default, the desktop icon to be used etc . Example of a config.xml file
Check out configuration file example to learn about other available elements
The other required folder is the packages folder. This is where you put what you essentially want to be installed on user’s system and also define the behavior of your installer. Everything that you want to be installed on user’s system is treated as a component by Qt Installer framework. Every component(com.elucidatainc.elmaven in the picture above ), which essentially exists as a folder, needs to have two sub-folders
- data – This folder contains the actual component, might be the actual application itself or something else that you want to ship along with your application
- meta – This folder is where you define things specific to that particular component. For example, the version of your component, the license file , the installer script itself(defines the operations performed by installer) .
Lets look at how package.xml and installer scripts look like
This is the file where you define the version of your application, the license file to be included in the installer , the UI file to be used for the installer (not required if you want to use the default UI) etc
Installer script is where you define the behavior of your installer. It lets you hide certain pages that you don’t want your users to go through , lets you define what operations your installer should perform. One of the things you would want to is to create a desktop shortcut for your application once the application has been installed. That can be achieved by using the “CreateShortcut” operation. Check out component scripting section to learn what more can be done using installer scripts
The data directory should contain the content that should be extracted on user’s system . The content should be present in 7z archive format, which essentially should include your application and all its dependencies, images etc. Qt provides tools like macDeployQt , winDeployQt that can be used to make deployable folder. Essentially they will club the dependencies together and make sure your application finds them during run time. This deployable folder can then be archived using archivegen tool, that comes with Qt Installer framework, and should be finally placed inside the data folder. The command for the same is:
archivegen app.7z path_of_deployable_folder
The last step is to use the binarycreator tool that will finally create the installer. The command for the same is :
binarycreator --ignore-translations -c config/config.xml -p packages/ name_of_the_installer
Had to switch to windows for this as Linux installers are still not ready. Anyway, that’s how the installers look like
The code for the same is hosted here . It still needs a lot of love and some new features like installers for Linux and a better UI.