3
votes

I created tray icon with context menu and attached its activated signal to slot in my dialog:

trayIconMenu = new QMenu(this);
trayIconMenu->addAction(showAction);
trayIconMenu->addAction(quitAction);

trayIcon = new QSystemTrayIcon(this);
trayIcon->setContextMenu(trayIconMenu);
trayIcon->setIcon(QIcon(":/images/gear.png"));
trayIcon->show();
trayIcon->showMessage(tr("SSTRNL-B"),tr("Message from tray icon!"));

QObject::connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
                 this,   SLOT(trayactivated(QSystemTrayIcon::ActivationReason)));

My slot is called when I click on tray icon. So everything is going right except I can not see context menu attached to QSystemTrayIcon.

In desktop systems we can use right-click on tray icon to see its context menu. But what am I supposed to do in Windows mobile/CE to see context menu?

1

1 Answers

1
votes

Check whether QSystemTrayIcon::ActivationReason==QSystemTrayIcon::Context in your SLOT. May be as you are using mobile App, click pattern for contextmenu might be different from General OS.

Ok if it is QSystemTrayIcon::Trigger, call trayIcon->contextMenu()->popup(QPoint&) in your SLOT, where QPoint is location of trayIcon.That would do.