PDA

View Full Version : Problem with application icon



sanjayshelke
8th September 2009, 08:00
Hi

I am getting strange problem with application icon. I have created sample application and trying to set the application icon using the setWIndowIcon().
I have created .rc file and added it to the .pro file.
When i run the application from visual studio, it shows the icon on top left of the main window.
But if i run the appliaction through explorer by doule clicking the .exe, it shows default icon.

.exe created did show the application icon. Bu the application is showing deafult icon.

If i put the icon file near b y .exe, then it correctly shows the icon on the top left corner.

It seems that there is problem with path of the icon file. But i believe that resources should get bundled with the .exe.

Can any one tell me whats going wrong.


Thanks in advance.


Regards,
~Sanjay

wysota
8th September 2009, 09:07
Application icon and window icon are two different things, so decide which one you want.

You are probably using a relative path to your icon and when the application is started from a different directory than you expect (as it takes place when double-clicking the icon in the desktop), the icon can't be located. Either use an absolute path or embed the icon into your application binary using Qt's resource system.

yogeshgokul
8th September 2009, 09:09
But i believe that resources should get bundled with the .exe.

they will get, when you supply em properly. See qt docs for it.
The Qt Resource System. (http://doc.trolltech.com/4.5/resources.html)

nish
8th September 2009, 09:47
qt resource system (qrc files) do embed the files(pics or anything) directly into the exe..
also the default resource files which you embed by visual studio are also inside the exe..
so in both cases there should be no need to supplying them with the files..

it seems your are setting the icon by its path, not the ":image/..." of qrc.. check it again.. or better provide a minimal compilable example.

sanjayshelke
8th September 2009, 10:21
Thanks.
We can embed the window icon into our application binary.
its working.

thanks a lot.