Reputation: 1463
I writing app and have strange bug in tray class. Inside my class I using QSystemTrayIcon
like
tray = new QSystemTrayIcon(this);
tray->setIcon(QIcon(":/gui/logo.png"));
...
tray->show();
On WinXP
and Windows7
it's working properly, but on Windows 8
icon is not displayed
qDebug()<<"System TRAY:"<< QSystemTrayIcon::isSystemTrayAvailable();// outputs true
I use Qt5.1.1 MSVC 2012
Upvotes: 2
Views: 2172
Reputation: 66
i just had the same problem, the solution i used from phyatt is to copy the imageformats folder to plugins folder of my apps, and it's working fine now.
Upvotes: 3
Reputation: 19152
Whether or not the system tray icon loads, I have found is more dependent on if it can load the file type.
Is the appropriate plugin available in your deployment environment?
http://www.qtcentre.org/threads/43152-Deploying-Qt-Application-on-Windows-Load-JPG-Images-Problem
http://qt-project.org/doc/qt-4.8/deployment-windows.html
Hope that helps.
UPDATE: Qt 5.1 w/ msvc 2012 32bit test results of QSystemTrayIcon
on Windows 8 Pro:
Compiling and building the test application with the following in a stock UI Form project,
with the following in the mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QSystemTrayIcon>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QSystemTrayIcon * sys = new QSystemTrayIcon(this);
// sys->setIcon(QIcon("C:/Users/phyatt/Downloads/system-tray.png"));
sys->setIcon(QIcon(":/gui/system-tray.png"));
sys->show();
}
MainWindow::~MainWindow()
{
delete ui;
}
And with these dependencies next to the exe, it runs just fine.
Upvotes: 2