A popup menu is a menu presented in a popup window. The menu implements a typical context menu, with support for submenu's.
When initially created, the menu is invisible, until popup() or exec() is called. Then, the menu will remain visible until an item is selected, or the user cancels the menu (by pressing the Escape key or clicking elsewhere).
WPopupMenu is similar in use to WDialog. So there are two ways of using the menu. The simplest way is to use one of the exec() methods, apply a reentrant event loop and wait until the user selected an item or cancelled the popup menu (by pressing Escape or clicking elsewhere).
Preferably, use one of the popup() methods to show the menu and listen to the aboutToHide signal where you read the result() (the last triggered menu item). If you listen to the aboutToHide signal of a parent popup it will also be triggered by its child popups.
You have several options to react to the selection of an item: