PDA

View Full Version : Add Application Icon without PRO file?



grantbj74
11th March 2010, 02:43
Hi,

My Windows and Linux application doesn't use a QT project file to compile.

Is it still possible to link a resource file ?

Maybe I need to add resource entry to my makefile instead ?

Think i'm using the borland compiler to make it.

Can anyone help ?

Thanks
Brendan

yogeshgokul
11th March 2010, 08:07
Hi,

My Windows and Linux application doesn't use a QT project file to compile.

Is it still possible to link a resource file ?

Maybe I need to add resource entry to my makefile instead ?

Think i'm using the borland compiler to make it.

Can anyone help ?

Thanks
Brendan

You are right, you need to make entry in Makefile. Because .pro file is the upper level of Makefile itself.
QMake converts .pro file into Makefile.

grantbj74
11th March 2010, 08:22
Thanks, do you know how I do this ?

I tried both of the following in the makefile declarations:


RC_FILE = myapp.rc

RESOURCE = myapp.qrc


I tried this in the main.cpp:


QApplication::setWindowIcon(QIcon(":/images/blue.png"));


This is one resource attempt (myapp.rc):


IDI_ICON1 ICON DISCARDABLE "blue.png"


This is the other resource attempt (myapp.qrc):


<RCC>
<qresource>
<file>images/blue.png</file>
</qresource>
</RCC>


All files are in the same folder.

wysota
11th March 2010, 09:42
I think you are mixing "application icon" and "window icon" terms and also "Windows resource file" and "Qt resource file" terms. And adding such pure statements into Makefile won't do anything, you need to write proper make rules to do that. RC_FILE and RESOURCES (not RESOURCE) are QMake statements.

mstegehu
11th March 2010, 13:54
As Wysota already said there is a difference in application icon and window icon:

Application Icon: The Icon visible on the application in an windows explorer or shortcut etc.
Window Icon: The icon visible on the top left MainWindow of your application (or dialogs or subwindows)

The Window Icon can be set with Widget::setWindowIcon or Application::setWindowIcon for top Left of main window.

The application can be set with: Set Application Icon (http://qt.nokia.com/doc/4.6/appicon.html)


IDI_ICON1 ICON DISCARDABLE "blue.png"

Be sure to use an ICON format and not a PNG format!

Regards,

Marcel

grantbj74
12th March 2010, 03:03
Thanks,

Thats handy to know that there is a difference between application and window icon.

I'm going to try to get the application icon going first.

I'm compiling in cygwin with mingw32 compiler. It still doesn't seem to use the icon.

Tried both resource declarations individually in mk file, and the following line is the qtapp.rc file:


RC_FILE += qtapp.rc
RESOURCES += qtapp.rc

IDI_ICON1 ICON DISCARDABLE "qtapp.ico"


I guess I need to do this, how do you do this ?


If you do not use qmake, the necessary steps are: first, run the rc program on the .rc file, then link your application with the resulting .res file.

wysota
12th March 2010, 09:30
You place respective entries in your Makefile. Or you start thinking - "hey, maybe I should use QMake after all?".

grantbj74
15th March 2010, 01:29
Yeah I might start using qmake temporarilly.

Unfortunately the company I work for has an autobuilder, and this would be the only application requiring qmake, so probably won't happen. :(

grantbj74
15th March 2010, 02:31
To get the application icon working I did the following in the mk file (I copied it from a similar application) :



LDRES += \
$(PROJECT)_res.o

$(PROJECT)_res.o: $(PROJECT).rc
$(BRCC32)

$(PROJECT): $(PROJECT)_res.o