I'm working with Qt/C++ creating my own app, I want it to be cross-platform, so far everything it's been working great with Qt, the only problem its with the tray-icon.
I create a tray-icon and add a menu to it, this works fine in windows but it's not working in Linux. I test my app in two computers and got two different respond.
In my desktop (Ubuntu 14.04) the tray-Icon appears on the right side of the task-bar as expected but it doesn't show me the menu. And in the laptop (also Ubuntu 14.04) the tray-icon appears on the left side of the task-bar but in this case it does shows me the menu and a message when I double click the icon.
I don't know if there's another way to do this but here it's my code.
if (QSystemTrayIcon::isSystemTrayAvailable())
{
//trayicon
trayIcon = new QSystemTrayIcon(this);
trayIcon->setIcon(QIcon(":/Imagenes/iconosPERFQ-23.png"));
trayIcon->setToolTip(tr("PerfQ Client"));
trayIcon->setVisible(true);
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
//Menu
logoutAction = new QAction(tr("&Logout"), this);
trayIconMenu = new QMenu(this);
trayIconMenu->addAction(logoutAction);
// Add the menu to the trayicon
trayIcon->setContextMenu(trayIconMenu);
connect (logoutAction,SIGNAL(triggered()), this, SLOT(logout()));
}
and the slot for the activated signal on the trayicon
void Task::iconActivated(QSystemTrayIcon::ActivationReason reason)
{
switch (reason)
{
case QSystemTrayIcon::DoubleClick:
QMessageBox::information(this,"Double Click", "Double click has been press on trayicon");
break;
default:
;
}
}