Taskbar icon different from the icon of the window



  • Hey guys.

    I would like to know is it possible to create 2 different icons. one for the window and another to the taskbar


  • Moderators

    Hi, welcome to devnet.

    Which OS do you mean? Taskbar icon usually represents the icon of the main window (as in the first top most window of the process). You can set different icons for dialogs or tool windows with QWidget::setWindowIcon.

    At least on Windows you can also use a different icon for shortcuts and pinned apps, but that is set up either manually from outside the app or using WinAPI.



  • [quote author="Chris Kawa" date="1409238075"]Hi, welcome to devnet.

    Which OS do you mean? Taskbar icon usually represents the icon of the main window (as in the first top most window of the process). You can set different icons for dialogs or tool windows with QWidget::setWindowIcon.

    At least on Windows you can also use a different icon for shortcuts and pinned apps, but that is set up either manually from outside the app or using WinAPI.[/quote]

    I'm using Windows 8.1, I wanted to just differentiate the icon title window icon in taskbar. There's no way to use Qt tools for this? I'm using Qt Creator 5.3


  • Moderators

    As I said - the taskbar icon is taken from the first top most window in your app. There is no Qt API to set different icons because the OS doesn't provide it (except for the pinned apps and shortcuts).
    Honestly - why would you want to do that anyway? Have you seen any app doing that? Wouldn't that be confusing to the user?



  • [quote author="Chris Kawa" date="1409254583"]As I said - the taskbar icon is taken from the first top most window in your app. There is no Qt API to set different icons because the OS doesn't provide it (except for the pinned apps and shortcuts).
    Honestly - why would you want to do that anyway? Have you seen any app doing that? Wouldn't that be confusing to the user?[/quote]

    I have the pleasure to make different icons.
    When I used Java was just define the sizes of icons in an array.
    I don't think it will be possible then, thanks for the help.


  • Moderators

    Well it's a bit of a trickery but if you create an .ico file with different sizes then you might get what you want. The window will use the small one (16px or 24px, I don't remember) while the task bar would use larger ones. To make it an application icon you put it in a resource file "as usually":http://qt-project.org/doc/qt-5/appicon.html.



  • I don't think it will be possible to do this.
    Could you tell me if you like at least remove the icon of the window?


  • Moderators

    [quote author="ReDKiiL" date="1409265345"]I don't think it will be possible to do this.[/quote]
    I actually tried this and it works.
    I created an icon with different images for various sizes (I know, I'm not da Vinci):!http://i296.photobucket.com/albums/mm188/crossblades666/icon.jpg(Icon)!

    And then set that as an app icon. As I said the app window uses the small one (16px) while tha task bar takes a larger one (32px):!http://i296.photobucket.com/albums/mm188/crossblades666/app.jpg(Application icon)!

    [quote author="ReDKiiL" date="1409265345"]Could you tell me if you like at least remove the icon of the window?[/quote]In Windows whether it has an icon or not depends on the window type and used windows flags. You can try to play around with window flags, eg.
    @ setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint); @ but you might loose some other features in the process. Check other flags and see what you can come up with. For example tool windows(Qt::Tool flag) don't have an icon by default (but they can't be top level windows).
    Another option is using the same trick as before: creating a fully transparent image for the 16px version. Of course this would also be invisible in the Explorer when someone switches to list view or other small icon mode.



  • [quote author="Chris Kawa" date="1409295819"]!http://i296.photobucket.com/albums/mm188/crossblades666/app.jpg(Application icon)!
    [/quote]

    Good! How did you do?
    What program you use to create the icons?


  • Moderators

    I did it "like I already described":http://qt-project.org/doc/qt-5/appicon.html
    I used built-in Visual Studio editor but it's not very sophisticated. Basically any graphics program that supports .ico format will do. Some that I know or used in the past are IcoFX (free up to 1.6.4), Gimp, Paint.NET (with ico plugin), Inkscape(vector graphics) or even Photoshop (with a plugin).



  • I have to add the files into .ico extension? or. bmp?
    I have to use the .rc file or add directly into the pro file?


  • Moderators

    That wiki page says it all but let me recap.
    If you don't already use a .rc file (which you most probably don't) then all you need to do is add in the .pro file
    @
    RC_ICONS = whatever.ico
    @

    .bmp format does not support multiple images in one file. .ico does. Use .ico.



  • How do I add more icons in just one line? in the pro file?

    I'm trying to searching, there are times when I'm trying to make this work.
    You could make your source code so I can see?


  • Moderators

    You don't add multiple files. It's a single file.
    .ico format supports multiple resolutions and bit depths inside a single file.
    It has nothing to do with code(or Qt) and there's nothing more to show than the above line in the .pro file.



  • How can I create an icon with multiple picture inside?
    I tried using Ico FX and GIMP. and I couldn't.


  • Moderators



  • Finally, I get it! Thank you for your patience.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.