Results 1 to 6 of 6

Thread: systray example: invisible icon when released under XP

  1. #1
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default systray example: invisible icon when released under XP

    Summary
    When launching the example "desktop/systray" on Qt 4.7 for Windows XP, everything works as expected. However, if I run the release file (systray.exe, with needed .dll files) independent of Qt, none of the icons load from the compiled resource file.

    Details
    The pull-down menu is missing the icons entirely and, if minimized to the system tray, a blank spot will show where an icon should be displayed.

    (I searched the forum first for a couple days without finding a working solution.)

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,709
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: systray example: invisible icon when released under XP

    (systray.exe, with needed .dll files)
    The example is using svg images, so you need to copy the svg plugin as well.
    Did you?

    EDIT:
    At least I THINK there should be an svg plugin (like for jpg etc).
    But I might be wrong.
    Look in the plugins directory of your Qt (I can't at the moment)
    Last edited by high_flyer; 20th December 2010 at 17:10.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. The following user says thank you to high_flyer for this useful post:

    Kayvon (20th December 2010)

  4. #3
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: systray example: invisible icon when released under XP

    Quote Originally Posted by high_flyer View Post
    The example is using svg images, so you need to copy the svg plugin as well.
    Did you?
    No.

    But I have now and it solved the problem perfectly. Many, many thanks to you. I had no idea the solution was so simple.

    I'm experienced in C++ but new to Qt. I guess my takeaway is that I need accompanying .dll files for everything listed under "QT += ..." in the .pro file, even if I don't receive an explicit error asking for it.

  5. #4
    Join Date
    Apr 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: systray example: invisible icon when released under XP

    Please help. I am having the same problem - the tray icon displays correctly on the machine where I build the project, but shows as a blank spot on any other machine.

    I am using VS2010 with the Designer plug-in, QT 4.7.2, on Windows. The icon is an .ico file, located in a sub-directory under the project directory. It has 16x16, 32x32, 64x64 sizes for 8 and 32 bit colors, no compression.

    I have confirmed that the icon is embedded correctly - I have been able to access it via QFile(":/<icon's path>"), moreover the tray icon area itself displays tooltips and messages without an issue. A built-in icon is displayed fine in any of these scenarios.

    Below is the code that creates, and tries to show, the tray icon:

    Qt Code:
    1. QIcon icon(":/QtManagerConsole/Resources/new.ico");
    2. trayIcon = new QSystemTrayIcon(icon, this);
    3. trayIcon->setToolTip(tr("Test Tooltip"));
    4. trayIcon->setVisible(true);
    5. //desperate attempts...
    6. trayIcon->setIcon(icon);
    7. trayIcon->show();
    8.  
    9. //Verifying that the file is embeded
    10. QFile file(":/QtManagerConsole/Resources/new.ico");
    11. qint64 size = file.size();
    12. trayIcon->showMessage("Icon loaded", QString("Size: %1").arg(size));
    To copy to clipboard, switch view to plain text mode 

    Thank you,
    Leo.
    Last edited by high_flyer; 7th April 2011 at 12:45. Reason: code tags

  6. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,709
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: systray example: invisible icon when released under XP

    So this icon is in a resource file correct?
    EDIT:
    QIcon docs:
    Use the QImageReader::supportedImageFormats() and QImageWriter::supportedImageFormats() functions to retrieve a complete list of the supported file formats.
    QPixmap docs:
    In addition, on Windows, the QPixmap class supports conversion to and from HBITMAP: the toWinHBITMAP() function creates a HBITMAP equivalent to the QPixmap, based on the given HBitmapFormat, and returns the HBITMAP handle. The fromWinHBITMAP() function returns a QPixmap that is equivalent to the given bitmap which has the specified format. The QPixmap class also supports conversion to and from HICON: the toWinHICON() function creates a HICON equivalent to the QPixmap, and returns the HICON handle. The fromWinHICON() function returns a QPixmap that is equivalent to the given icon.
    Last edited by high_flyer; 7th April 2011 at 13:02.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #6
    Join Date
    Apr 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: systray example: invisible icon when released under XP

    The icon was in the resource file, yes.
    I resolved the problem. First, Installing the icon plugin (\imageformats\qico4.dll) on the target machine solved the problem with ICO files. Secondly, using a PNG icon does not require a plugin at all.
    Useful documentation can be found at: http://doc.qt.nokia.com/4.7/deployment-plugins.html
    Thanks for the help!
    Leo.

Similar Threads

  1. dynamic systray icon
    By mattie in forum Qt Programming
    Replies: 6
    Last Post: 13th December 2010, 05:21
  2. Replies: 3
    Last Post: 18th May 2010, 12:52
  3. Animated graphical widget in systray. howto?
    By Tetractys in forum Newbie
    Replies: 2
    Last Post: 6th October 2009, 23:51
  4. systray: icon does not display in windows server 2003
    By lovelypp in forum Qt Programming
    Replies: 0
    Last Post: 23rd September 2008, 10:47
  5. How can I get the Systray height ?
    By Nyphel in forum Qt Programming
    Replies: 3
    Last Post: 12th March 2007, 09:04

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.