Hi,

I have 2 QMenus (trayIconMenu1 and trayIconMenu2).

Qt Code:
  1. QMenu *trayIconMenu1 = new QMenu(this);
  2. QMenu *trayIconMenu2 = new QMenu(this);
To copy to clipboard, switch view to plain text mode 

The first QMenu popups itself when i right click the icon in the system tray. I popup the second one when i left click the icon in the system tray.

Qt Code:
  1. trayIconMenu2->popup(QCursor::pos());
To copy to clipboard, switch view to plain text mode 

The problem is that the second one does not automatically close whenever i click outside the menu. The first one does close automatically.

I tried to inherit QMenu and overwrite mousePressEvent, changeEvent, focusOutEvent, event. I also tried these functions in the parent widget, which is a QDialog. None of these functions are called when I click outside the popup.

What event should I use so that the second QMenu automatically closes? Or is there something else I need to do?

Thx