# How to create a .qs file

• Hello,

For my project that I waited for three days and didn't get any reply (!), here, I need some .qs file named installscript.qs.
I searched the Web and also some parts of Docs but could't find any clear solution for creating that file!
I think the problem of my program is likely that I don't have such a file.
If possible please tell me how to create that file.

Thanks.

• hi
Its mentioned here in this example

I think you just make it by hand. seems to be a script file.

• Thank you for the answer.

My config.xml is the same as the Docs:

<?xml version="1.0" encoding="UTF-8"?>
-<Installer>
<Name>Qt Calculator</Name>
<Version>1.4.0</Version>
<Title>Qt Framework Installer</Title>
<Publisher>Abbasi</Publisher>
<TargetDir>@HomeDir@/InstallationDirectory</TargetDir>
</Installer>


In the package.xml apparently I also need a .ui file. (pageform.ui):

<?xml version="1.0" encoding="UTF-8"?>
-<Package>
<DisplayName>Qt Calculator</DisplayName>
<Description>A Calculator Written in Qt by Purely C++ Code</Description>
<Version>1.4</Version>
<ReleaseDate>2017-07-17</ReleaseDate>
<Name>com.vendor.root</Name>
<Virtual>false</Virtual>
<Default>true</Default>
<Script>installscript.qs</Script>
-<UserInterfaces>
<UserInterface>pageform.ui</UserInterface>
</UserInterfaces>
</Package>


In the Docs, it says: In installscript.qs, we use the Component() function. But while I still don't have such a file how can write into it!!? My program still lacks it.

I then switched to the resource directory (the data folder) by CMD and ran this command (as in the Dos):

C:\Users\Abbasi\Desktop\package_directory\packages\com.vendor.product\data> C:\Qt\QtIFW2.0.1\bin\binarycreator.exe -c C:\Users\Abbasi\Desktop\package_directory\config\config.xml -p C:\Users\Abbasi\Desktop\package_directory\packages Qt_Calculator.exe

I got some errors.

seems to be a script file

Yes it is a script file, and my question is how to have such a file please?

• @tomy

I had used one of the example section as delivered with QTIFW. There is already a newer version QtIFW 2.0.5 available. There are a couple of different of installscript.qs there.

Btw, Funnily, your other post is listed as 2 days ago. Is this an issue with crossing the date line?

Also this is a user forum. You are hardly getting repsonses on issues with Qt IFW.

• @tomy said in How to create a .qs file:

Yes it is a script file, and my question is how to have such a file please?

Have you tried Just to create a new empty file and renamed it to installscript.qs ?

• @koahnig

I had used one of the example section as delivered with QTIFW. There is already a newer version QtIFW 2.0.5 available. There are a couple of different of installscript.qs there.

I searched for that 2.0.5 for my Windows but didn't find, instead I downloaded qt-installer-framework-opensource-2.0.5-src and could find many installscript.qs files. I picked one plus an empty .ui file and named it to pageform. It's empty.
for the installscript.qs I put the code below into it after clearing its previous data.

function Component()
{
// Install to @RootDir@ instead of @HomeDir@ on Windows
if (installer.value("os") === "win") {
var homeDir = installer.value("HomeDir");
var targetDir = installer.value("TargetDir").replace(homeDir, "@RootDir@");
installer.setValue("TargetDir", targetDir);
}

// do not show component selection page
installer.setDefaultPageVisible(QInstaller.ComponentSelection, false);
// no startmenu entry so no need to ask where to create it
}


Now seemingly I have all needed stuffs. I re-ran the command in a CMD and again got errors! :(

Also this is a user forum. You are hardly getting repsonses on issues with Qt IFW.

Dont' millions of programmers create installers for their apps? Is there any simpler and easier means to create installers for our apps. If someone writes a code, they are more eager to create an installer for that, I suppose.

• @mrjj

Have you tried Just to create a new empty file and renamed it to installscript.qs?

Not honestly. But how to? What Project or Classes on Qt Creator IDE?

• @tomy
Just right click and create a text file then rename it. ( in your installer project folder)
Its just a text file type and you add the commands manually.
Seems to be nothing special you need to do.

• @mrjj
Very nifty mrjj. Thanks. :)

Some points in my mind:

• Is the command I use (in CMD) correct?
• Is it acceptable even if the pageform.ui file has nothing special?

• @tomy
Hi
Ï have never used the installer framework so I cant tell.
Did you try the simple example
http://doc.qt.io/qtinstallerframework/ifw-tutorial.html
to get to know it ?

• Hi,
Yeah, I used it. There should be some issue in paths in my stuff. :(

• @tomy
with spaces or what kind of issues?

• Please take a look at this:
https://postimg.org/image/kaf5gm31t/

• @tomy
Oh, there is something in the files it dont like. it seems.

When you tried the example , no errors were displayed?

• @mrjj
The code is of months ago but the Qt_Calculator.exe of Release mode now works fine in the data folder.
I think the problem is of either installscript.qs file or pageform.ui file. :(

• @tomy
But the errors seems to point to package.xml ?

• This is the contents of that file:
https://postimg.org/image/hsuszqcel/

I see nothing clearly wrong in it.

• @tomy
well the errors says it wont use name, but i fail to see the "meta" it talks about.
It also says the default and virtual should not be used together so maybe try to remove one?

• @mrjj
Well it worked, not completely although. :)

I removed that virtual line in the package.xml. And it is in the meta folder. Please look:
https://postimg.org/image/u84mw60p9/

Then re-done the command. It again returned some issues:
https://postimg.org/image/y1wdy7ihz/

It finally created an installer in the Result folder on desktop. But It doesn't put a shortcut of the program on desktop, and it's the contents of the installation folder:
https://postimg.org/image/kvdfu4zcb/

I think now I should somehow change the contents of installscript.qs file.

• @tomy
Yes the installscript.qs should contain the actual
code to execute while installing.

• Yes, it seems to be the last important issue on the app. How to change it to work fine, please?
This is its code:

function Component()
{
// Install to @RootDir@ instead of @HomeDir@ on Windows
if (installer.value("os") === "win") {
var homeDir = installer.value("HomeDir");
var targetDir = installer.value("TargetDir").replace(homeDir, "@RootDir@");
installer.setValue("TargetDir", targetDir);
}

// do not show component selection page
installer.setDefaultPageVisible(QInstaller.ComponentSelection, false);
// no startmenu entry so no need to ask where to create it
}


• @tomy
That i dont know
It seems to be commands from
http://doc.qt.io/qtinstallerframework/scripting.html

So you will also need some copy commands from ( i think)
http://doc.qt.io/qtinstallerframework/operations.html

• OK, mate. I will read both posts precisely and will post again to you here about the results.

• I read the pages and changed the installscript.qs to this:

function Component()
{
if (installer.value("os") === "win")
{
installer.setValue("ApplicationsDir", "ApplicationsDir");
}
}


My purposes were to first make the app be installed in C:\ProgramFiles folder and then to have a shortcut of the app on my Desktop.
The data folder contains a Qt_Calculator.icon file. These are all contents of that folder:
https://postimg.org/image/f3fddnww5/

Then I again used this command:
C:\Users\Abbasi\Desktop\package_directory\packages\com.vendor.product\data> C:\Qt\QtIFW2.0.1\bin\binarycreator.exe -c C:\Users\Abbasi\Desktop\package_directory\config\config.xml -p C:\Users\Abbasi\Desktop\package_directory\packages C:\Users\Abbasi\Desktop\Result\Qt_Calculator.exe

I got an error and a warning as below:
https://postimg.org/image/w6p5ajr25/

At the end, it created the installer but it works this way:
It creates an installer file in the Result folder and have the default path of C:\Users\Abbasi for installation and after installing it creates no shourcut on the Desktop.

• @tomy
I used this

Component.prototype.createOperations = function()
{
try {
// call the base create operations function
component.createOperations();
if (installer.value("os") == "win") {
try {
var userProfile = installer.environmentVariable("USERPROFILE");
installer.setValue("UserProfile", userProfile);
} catch (e) {
// Do nothing if key doesn't exist
}
}
} catch (e) {
print(e);
}
}

• Thank you for your reply, I used your code and only changed MyApp to Qt_Calculator but it even didn't create the installer! :( :(

Component.prototype.createOperations = function()
{
try {
// call the base create operations function
component.createOperations();
if (installer.value("os") == "win") {
try {
var userProfile = installer.environmentVariable("USERPROFILE");
installer.setValue("UserProfile", userProfile);
} catch (e) {
// Do nothing if key doesn't exist
}
}
} catch (e) {
print(e);
}
}


I used the command below and got errors:

And my data folder consists of:

• Hi @tomy the QInstallerFramework can be confusing, especiall if you don't have a workign example, like it seems to be the case for you.

I went and uploded the InstallerFramework example for an Installer with a -Windows- Start Menu entry.

Let's see if the fileupload system of the updated forum works:
seems like a admin/mod only thing.

It boils down to a few steps that we can walk through, if you want to.

if you unzip the file, you get a folder with 2 subfolders config and packages
in the config folder you'll find the config.xml,

In packages you'll find 2 folders data and meta. in Data you place all needed dlls files exe's you need to run your Application without Qt-Installed on your system.

In meta you place the installer script file additional ui-files licenzes etc.

Now open your cmd-line tool on windows.

Win-Key + R
cmd
Enter //ctrl +shift+ enter for elevated rights

//cd to your folder that contains config- and packages folders

//now enter:
c:\Path\to\QtInstallerFrameWork\bin\binarycreator.exe --offline-only -c config\config.xml -p packages TheNameYourInstallerShallHave.exe


let's see if you still get errors.

• Hmm, only some types are allowed it seems. ( even for mods)

• Thank you very much all.
The program/process works fine now.

I think I can use this process for any other new example too, with probably some modifications of course.

I have some questions that will be helpful for my information if they are answered.

1- What is that .ui file for? (while it contains almost nothing!)
2- You programmers do program, but don't you create installers for them? If not, so how could they be useful? And if yes, what tool (if not Qt Installer Framework) do you use for that?
3- Are the errors/warns I get while running the CMD command unimportant and should I ignore them?

Thanks.

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