Results 1 to 8 of 8

Thread: setting main application icon on windows

  1. #1
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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:
    Qt Code:
    1. IDI_ICON1 ICON DISCARDABLE "myapp.ico"
    To copy to clipboard, switch view to plain text mode 

    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.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setting main application icon on windows

    If you are talking about Qt app on windows,
    QApplication::setWindowIconor QWidget::setWindowIcon might help you

  3. #3
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setting main application icon on windows

    Hi,

    Quote Originally Posted by aamer4yu View Post
    If you are talking about Qt app on windows,
    QApplication::setWindowIconor QWidget::setWindowIcon might help you
    Well these are runtime only. In explorer you will not see icons you set this way.
    Thanks anyway.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: setting main application icon on windows

    Quote Originally Posted by JeanC View Post
    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:
    Qt Code:
    1. IDI_ICON1 ICON DISCARDABLE "myapp.ico"
    To copy to clipboard, switch view to plain text mode 

    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.
    J-P Nurmi

  5. #5
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setting main application icon on windows

    Hi jpn,

    Quote Originally Posted by jpn View Post
    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.
    Last edited by JeanC; 22nd September 2008 at 13:47.

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default 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".
    J-P Nurmi

  7. #7
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setting main application icon on windows

    Yes that was the solution. pf

    Great.
    Thanks again.

  8. #8

    Default 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...

Similar Threads

  1. Start Qt application as Windows Service
    By ^NyAw^ in forum Qt Programming
    Replies: 12
    Last Post: 10th May 2008, 18:23
  2. Couple of questions: main window icon + toolbar icon
    By bpackard in forum Qt Programming
    Replies: 0
    Last Post: 20th March 2008, 20:03
  3. Mac application and the Dock Icon
    By sekelsenmat in forum Qt Programming
    Replies: 3
    Last Post: 26th September 2007, 11:23
  4. Setting default icon for all windows / dialogs
    By steg90 in forum Qt Programming
    Replies: 1
    Last Post: 5th July 2007, 11:04
  5. Replies: 3
    Last Post: 31st March 2006, 19:38

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.