ich habe unter qt 4.2.3 das SystemTray-Beispiel kompiliert, läuft einwandfrei. In meiner Anwendung habe ich das Problem, dass das Icon (hier unter Gnome) zwar angezeigt wird, aber auf nichts reagiert - kein Kontextmenu, kein Tooltip, keine Klick-Events. Der Balloon-Hint hingegen läuft. Die Konsole gibt keine Fehlermeldungen oder Warnungen, weder beim Kompilieren noch zur Laufzeit.
ein paar Codeschnipsel:
window.h:
Code: Alles auswählen
private:
// System tray icon
QSystemTrayIcon* trayIcon;
// System tray menu
QMenu* trayIconMenu;
Code: Alles auswählen
Window::Window()
{
createMenu();
createTrayIcon();
[...]
Code: Alles auswählen
void Window::createTrayIcon()
{
setWindowIcon(QIcon("images/computer-16.png"));
trayIconMenu = new QMenu(this);
trayIconMenu->addAction(actionExit);
actionHide = new QAction(tr("&Ausblenden"), this);
connect(actionHide, SIGNAL(triggered()), this, SLOT(hide()));
actionRestore = new QAction(tr("&Zeigen"), this);
connect(actionRestore, SIGNAL(triggered()), this, SLOT(showNormal()));
trayIcon = new QSystemTrayIcon(this);
connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked()));
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
trayIcon->setContextMenu(trayIconMenu);
trayIcon->setIcon(QIcon("images/bad.svg"));
trayIcon->setToolTip("Serverstatus");
trayIcon->show();
}Wäre nett, wenn jemand eine Idee hätte.
Viele Grüße
Stefan