2
votes

I want to deploy an application to windows using the Qt installer framework. I have some problems setting the icon in the taskbar. I am using

  • Qt Creator Version 4.7.2
  • qmake
  • Desktop Qt 5.11.2 MinGW 32 bit

If I run the application inside Qt Creator the application shows up with an icon in the taskbar.

To deploy it to Windows I do the following steps:

  1. Build the application as release
  2. Copy the created .exe inside the data folder of the installer framework
  3. Run the following command to Link everything together:

    windeployqt.exe --no-translations --no-quick-import E:\path\to\app.exe

  4. Run the following command to create the installer:

    D:\Qt\InstallerFramework\bin\binarycreator.exe --offline-only -c config/config.xml -p packages app_Setup

After that, I get the setupt.exe which I can successfully install on another PC. If I start the application now the icon of the app is missing I only get this standard icon from windows:

enter image description here

So now to what I did:

I have a .qrc file which has the following entry:

<RCC>
    <qresource prefix="/">
        <file>icon.ico</file>
    </qresource>
</RCC>

and an additional .rc file with the following content

IDI_ICON1               ICON    DISCARDABLE     "icon.ico"

Inside the .pro file I added

RC_FILE = resources.rc
RESOURCES = qresources.qrc

I assigned the icon with Qt Designer as the icon of the main window. Put the following line into the constructor of MainWindow:

setWindowIcon(QIcon("://icon.ico"));

I also checked after running windeployqt if the necessary dlls are in the folder imageformats (I mean the qico.dll)

Still after all of that I don't get any icon inside the taskbar (also it has no icon inside the start menu). The .exe has the right icon.

I searched alot and those are the steps everybody suggested so I don't know why it is not working.

If I start the .exe after creating it with windeployqt the application has a icon inside the taskbar.

After installing it with the created setup the icon is missing. (the qico.dll is present inside the installation folder also)

So I am missing something by creating the setup? Perhabs any of you have a idea.

Thank you!

1
Can you confirm the correct spelling (Icon.ico or icon.ico) and setWindowIcon(QIcon(":/icon.ico")); with only one / instead of //. - Jens
Spelling is wrong. Changed it. Thank you... Double dashes should be also right because of the prefix in qresource - Sorkfa
Is the resource really compiled in? For this, rc.exe needs to be in the binary folder where the mingw compiler is located. There were Qt setups, where rc.exe was missing. Can you see the image, if you open your exe in Visual Studio as a file (Opening it there should display the complete resource information)? - Jens
I will check that later today. Strange part is: If is I open the standalone application created with windeployqt the icon shows up in the taskbar. It is missing after creating the setup (with qt installer framework) and installing it with the setup. - Sorkfa
@Jens I diffed the two .exe (the one from the setup installer and the one after running windeployqt) they are completely the same. Also, I again checked all dlls. They are also the same in both folders. - Sorkfa

1 Answers

0
votes

I had the very same problem, as described above. Of particular note is that when running the application in the folder used to create the installer, the icon shows, after installing and running from the installation folder, the icon is incorrect (the windows default).

For this to happen I believe the installer is setting a registry entry for that specific directory to have the default win icon, since moving the .exe to a different directory resolves the issue.

Looking in the installation log, revealed a clue, there was mention of an icon at %system32% (I had lifted an example installscript.qs from the Qt website) found in the meta folder.

Start by removing all mention of an icon in this script. This will not fix it, the damage appears to be done, since a registry entry is already made for that folder path. The final fix, was to change where the installation goes and then finally the icon now displays. This took me a number of very frustrating hours to figure out!