PDA

View Full Version : Adding Icons



bijan311
27th March 2010, 20:16
I have tried doing


MY_ICON ICON "C:\users\bijan\pictures\program icons\icon.ico"

but the icon only shows up in the desktop but it doesn't show up in the actual program (you can see what I mean in the attachments).
I have also tried


QApplication::setWindowIcon(QIcon(" C:\users\bijan\pictures\program icons\icon.ico"));

but that distorts the picture.

Thank you in advance

waynew
27th March 2010, 22:12
Did you add the icon file to your application.qrc in Creator?

toutarrive
27th March 2010, 22:43
To set the application icon have look at : http://qt.nokia.com/doc/4.6/appicon.html

The icon of the executable file is the one used by a shortcut or by windows explorer.
Create a file called appIcon.rc with the following:

IDI_ICON1 ICON DISCARDABLE "appIcon.ico"
And then add this line to your *.pro file:

RC_FILE = appIcon.rc

To set the window icon (the one visible at the top left corner of your main window), use
QApplication::setWindowIcon (const QIcon& icon) or QWidget::setWindowIcon(const QIcon& icon).