PDA

View Full Version : Application Icons



abrou
25th January 2008, 19:53
Hello, I am using Qt4 with Visual C++ 2005 Express Edition, and I am struggling to figure out how to change the icon of my .exe generated. I am a fairly new programmer, definetly new to Qt and since I am self taught, I don't understand much about resources. I have spent many hours so far, trying to follow the steps in Setting the Application Icon (http://www.cs.queensu.ca/~dalamb/qt/local/appicon.html) but it was having a linking error, so I tried the advice similar to the Arthur Plugin example that Qt gives. It compiles, but the icon is still the default .exe one. I already have a .ico file, but it is not working. Can somebody maybe help me understand the steps so I can fix this problem? Can I give anymore information that might help you help me? Thank you very much!

Anna

wysota
25th January 2008, 20:38
Trying with newer docs might be a good place to start:

http://doc.trolltech.com/4.3/appicon.html

abrou
25th January 2008, 21:42
I'm sorry, I did use that one. It was in the Qt Assistant, so I just tried to find a link, but apparently it was the wrong one.

wysota
25th January 2008, 23:49
So at what point you got stuck? Have you created the .rc file? It's a regular text file, you might create it even in notepad.

abrou
28th January 2008, 17:19
As I said, I ended up following an example similar to the arthur plugin example that qt gives, which uses a .qrc file instead of a .rc (which I don't know the difference between). My .qrc file looks like this:

<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/res">
<file>Launcher.ico</file>
</qresource>
</RCC>

The .ico file is in the project's directory.

I'm not sure where the problem occurs, everything compiles and links fine (I think) but the icon does not change. Is there something I am missing? Thank you!

wysota
28th January 2008, 17:38
The resource file you need to create is to be a Windows resource file, not Qt resource file. The docs clearly say what to place inside the .rc file. Let me quote it for you:


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.

abrou
28th January 2008, 17:55
I'm stunned, because last thursday and friday I used those exact instructions many times and just continued to get a linking error that I couldn't resolve (and yes, i was using a .rc file then). Monday morning comes and it works! I wish I knew why, but I'm still happy it is.

One last question, do you know an open source program that I can use to create icons with? I am using visual studio express which isn't helpful for such things.

Again, Thanks!

wysota
28th January 2008, 20:05
There are many icon editors available. You can even use MS Paint for that. If you want more advanced features I recommend GIMP, but it's hard to use in the beginning.