I have a QMenu that in a QSystemTrayIcon. Both are members of a QMainWindow object.
I wan the QMenu of the QSystemTrayIcon to act exactly alike when right clicking (ie, reason QSystemTrayIcon::Context) and when single left clicking (ie, reason QSystemTrayIcon::Trigger).
The right clicking behavior by default acts like I want it to. However I can't figure out how to make the left click act exactly like right click. My efforts so far lead me to:
void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason)
{
if(reason==QSystemTrayIcon::Trigger) trayIcon->contextMenu()->popup(QCursor::pos());
}
However, the menu doesn't disappear when it loses focus whereas bringing up the contextmenu with right click does make it disappear when focus is lost.
Is there away to make Trigger act like Context? Maybe a way to throw a mock signal or something?