setting main application icon on windows
I'm using qt on windows with mingw32-make.
I'm trying to set the main application icon in windows apps like documented in the help.
If I run 'rcc myapp.rc' I get 'RCC Parse Error: 'myapp.rc' Line: 1 Column: 2 [error occurred while parsing element]'
This is myapp.rc:
Code:
IDI_ICON1 ICON DISCARDABLE "myapp.ico"
If I don't use rcc and just try to add the 'RC_FILE=myapp.rc' I get the error 'no rule to make target myapp.rc needed by build/myapp_res.o'.
Now what is the correct way to set an application icon on windows please?
(ps. I wish windows builds would automatically add the default qt mainicon in stead so that 'empty' doswindow icon doesn't show up)
Thanks.
Re: setting main application icon on windows
If you are talking about Qt app on windows,
QApplication::setWindowIconor QWidget::setWindowIcon might help you
Re: setting main application icon on windows
Hi,
Quote:
Originally Posted by
aamer4yu
Well these are runtime only. In explorer you will not see icons you set this way.
Thanks anyway.
Re: setting main application icon on windows
Quote:
Originally Posted by
JeanC
If I run 'rcc myapp.rc' I get 'RCC Parse Error: 'myapp.rc' Line: 1 Column: 2 [error occurred while parsing element]'
RCC parses .qrc files, not .rc files.
Quote:
This is myapp.rc:
Code:
IDI_ICON1 ICON DISCARDABLE "myapp.ico"
If I don't use rcc and just try to add the 'RC_FILE=myapp.rc' I get the error 'no rule to make target myapp.rc needed by build/myapp_res.o'.
Does the file name match? Is myapp.rc in correct folder?
Quote:
Now what is the correct way to set an application icon on windows please?
You're very close. There must be a small mistake somewhere. Check that the path and file name matches and re-run qmake just to be sure.
Re: setting main application icon on windows
Hi jpn,
Quote:
Originally Posted by
jpn
RCC parses .qrc files, not .rc files.
Yes, the docs talk about rc.exe but there is no rc.exe that I can find.
Quote:
Does the file name match? Is myapp.rc in correct folder?
In the src folder like the help says.
Quote:
You're very close. There must be a small mistake somewhere. Check that the path and file name matches and re-run qmake just to be sure.
I will try again as I get around to it, too busy ATM.
Edit: Just tried again, no succes.
The app is called 'cal', it's a calendar of sorts, cal.pro has a line 'RC_FILE = cal.rc' , theres a src/cal.ico and src/cal.rc which contains 'IDI_ICON1 ICON DISCARDABLE "cal.ico'.
running qmake gives no errors but there's no icon.
I must be doing something wrong still.
Thanks jpn.
Re: setting main application icon on windows
Where is cal.pro? Unless it's also in src/, it should be "RC_FILE = src/cal.rc".
Re: setting main application icon on windows
Yes that was the solution. pf :)
Great.
Thanks again.
Re: setting main application icon on windows
Test if you have a space in some folder in your path to the project.
Example: D:\Lab\QtProjects\MyNotepad 1.0
This make that cannot recognize "windres"
Do the follow:
-Delete the pro.user file in your project root directory
-rename without spaces (Ex: D:\Lab\QtProjects\MyNotepad-1.0)
-in Qt Creator -> Open Project -> mynotepad.pro (following the example)
Compile and Voilé.... All ok!!
Try...