Results 1 to 9 of 9

Thread: Add Application Icon without PRO file?

  1. #1
    Join Date
    Aug 2009
    Location
    Brisbane, Australia
    Posts
    75
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Add Application Icon without PRO file?

    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

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Add Application Icon without PRO file?

    Quote Originally Posted by grantbj74 View Post
    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.

  3. #3
    Join Date
    Aug 2009
    Location
    Brisbane, Australia
    Posts
    75
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Add Application Icon without PRO file?

    Thanks, do you know how I do this ?

    I tried both of the following in the makefile declarations:
    Qt Code:
    1. RC_FILE = myapp.rc
    2.  
    3. RESOURCE = myapp.qrc
    To copy to clipboard, switch view to plain text mode 

    I tried this in the main.cpp:
    Qt Code:
    1. QApplication::setWindowIcon(QIcon(":/images/blue.png"));
    To copy to clipboard, switch view to plain text mode 

    This is one resource attempt (myapp.rc):
    Qt Code:
    1. IDI_ICON1 ICON DISCARDABLE "blue.png"
    To copy to clipboard, switch view to plain text mode 

    This is the other resource attempt (myapp.qrc):
    Qt Code:
    1. <RCC>
    2. <qresource>
    3. <file>images/blue.png</file>
    4. </qresource>
    5. </RCC>
    To copy to clipboard, switch view to plain text mode 

    All files are in the same folder.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Add Application Icon without PRO file?

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Sep 2008
    Posts
    54
    Thanks
    3
    Thanked 10 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    2

    Default Re: Add Application Icon without PRO file?

    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

    IDI_ICON1 ICON DISCARDABLE "blue.png"
    Be sure to use an ICON format and not a PNG format!

    Regards,

    Marcel

  6. #6
    Join Date
    Aug 2009
    Location
    Brisbane, Australia
    Posts
    75
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Add Application Icon without PRO file?

    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:
    Qt Code:
    1. RC_FILE += qtapp.rc
    2. RESOURCES += qtapp.rc
    3.  
    4. IDI_ICON1 ICON DISCARDABLE "qtapp.ico"
    To copy to clipboard, switch view to plain text mode 

    I guess I need to do this, how do you do this ?
    Qt Code:
    1. 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.
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Add Application Icon without PRO file?

    You place respective entries in your Makefile. Or you start thinking - "hey, maybe I should use QMake after all?".
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Aug 2009
    Location
    Brisbane, Australia
    Posts
    75
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Add Application Icon without PRO file?

    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.

  9. #9
    Join Date
    Aug 2009
    Location
    Brisbane, Australia
    Posts
    75
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Re: Add Application Icon without PRO file?

    To get the application icon working I did the following in the mk file (I copied it from a similar application) :

    Qt Code:
    1. LDRES += \
    2. $(PROJECT)_res.o
    3.  
    4. $(PROJECT)_res.o: $(PROJECT).rc
    5. $(BRCC32)
    6.  
    7. $(PROJECT): $(PROJECT)_res.o
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Application icon - Qt S60
    By ppaluch in forum Qt for Embedded and Mobile
    Replies: 5
    Last Post: 23rd November 2010, 11:17
  2. How to set the application icon in Linux?
    By live_07 in forum Newbie
    Replies: 11
    Last Post: 24th September 2010, 09:39
  3. Problem with application icon
    By sanjayshelke in forum Qt Programming
    Replies: 4
    Last Post: 8th September 2009, 10:21
  4. compile icon into application
    By BlackFoXX in forum Qt Programming
    Replies: 4
    Last Post: 1st May 2009, 21:41
  5. Change Application Icon
    By cutie.monkey in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2008, 07:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.