Question

In my last question (Qt/C++: Icons not showing up when program is run) I asked how to get an icon to show up on a toolbar and was told I needed a Qt Resource, which I added and that fixed my problem, the icon did show up on the toolbar.

Now I'm trying to set the title icon of a window, using the same resource file, and it shows up fine in the Qt preview viewer but blank in the actual program. I am using a MainWindow which has an MDIArea and the children are MainWindows as well; neither the parent MDI nor child MDI windows icons will show properly. On the parent, I see the regular "Windows Application icon" and on the child, the icon is completely blank.

How can I solve this?

Was it helpful?

Solution

You will have to go through a standard resource file for windows. (That is, a .rc)

The process (as described in the documentation) is:

Store the ICO file in your application's source code directory, for example, with the name myappico.ico. Then, create a text file called, say, myapp.rc in which you put a single line of text:

IDI_ICON1 ICON DISCARDABLE "myappico.ico"

Finally, assuming you are using qmake to generate your makefiles, add this line to your myapp.pro

file: RC_FILE = myapp.rc

Regenerate your makefile and your application. The .exe file will now be represented with your icon in Explorer.

In the Visual Studio case you're simply able to add a resource to your project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top