PDA

View Full Version : systray example: invisible icon when released under XP



Kayvon
20th December 2010, 18:02
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.)

high_flyer
20th December 2010, 18:05
(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)

Kayvon
20th December 2010, 18:13
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.

leodor
7th April 2011, 10:16
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:


QIcon icon(":/QtManagerConsole/Resources/new.ico");
trayIcon = new QSystemTrayIcon(icon, this);
trayIcon->setToolTip(tr("Test Tooltip"));
trayIcon->setVisible(true);
//desperate attempts...
trayIcon->setIcon(icon);
trayIcon->show();

//Verifying that the file is embeded
QFile file(":/QtManagerConsole/Resources/new.ico");
qint64 size = file.size();
trayIcon->showMessage("Icon loaded", QString("Size: %1").arg(size));

Thank you,
Leo.

high_flyer
7th April 2011, 13:55
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.

leodor
10th April 2011, 13:25
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.