Reading the Qt5 source code, I noticed that QLabel::contextMenuEvent() uses this (non-blocking) style:
QMenu *menu = ...
menu->setAttribute(Qt::WA_DeleteOnClose);
// Non-blocking
menu->popup(event->globalPos());
Alternatively, I have seen this (blocking) style from Qt code samples:
QMenu *menu = ...
// Blocking
QAction* action = menu->exec(event->globalPos());
// Or before menu->exec() call: menu->setAttribute(Qt::WA_DeleteOnClose)
delete menu;
I can see these differences:
- Non-blocking vs blocking
- Return
voidvsQAction*
Are their other differences? Example: Is there an advantage to non-blocking, e.g., the event loop can process other events? If the difference is purely style, please let me know.
Finally, I do notice that debugging the non-blocking style is a little bit weird for me on GNU/Linux/KDE, but that might be unrelated.