View Full Version : setting main application icon on windows
JeanC
20th September 2008, 10:48
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:
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.
aamer4yu
20th September 2008, 19:53
If you are talking about Qt app on windows,
QApplication::setWindowIcon
or QWidget::setWindowIcon might help you
JeanC
21st September 2008, 07:53
Hi,
If you are talking about Qt app on windows,
QApplication::setWindowIcon
or QWidget::setWindowIcon might help you
Well these are runtime only. In explorer you will not see icons you set this way.
Thanks anyway.
jpn
22nd September 2008, 07:10
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.
This is myapp.rc:
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?
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.
JeanC
22nd September 2008, 10:41
Hi 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.
Does the file name match? Is myapp.rc in correct folder?
In the src folder like the help says.
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.
jpn
22nd September 2008, 13:29
Where is cal.pro? Unless it's also in src/, it should be "RC_FILE = src/cal.rc".
JeanC
22nd September 2008, 17:03
Yes that was the solution. pf :)
Great.
Thanks again.
marcelognunez
12th June 2017, 05:35
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...
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.