I found a workaround: do my post-context-menu work when focus is returned to another window. That is, connect a handler to QApp.focusWindowChanged.
To be clear about the problem: my model layer (in C++ or Python) is emitting a signal to the UI layer (QML) to show a Menu (context menu) in a QQuickWindow. Execution continues in the model after emitting the signal (not synchronous.) The context menu receives focus (but I’m not sure what events the model continues to receive, i.e. it might be receiving mouseMoveEvents? That is, I’m not sure the context menu is modal in the sense that it is the only window receiving pointer and key events). After the user chooses an item of the context menu, or clicks outside of it, focus is returned to the main window and the model receives a focusWindowChanged signal. In the handler, the model unhighlights (unselects) the operand of the context menu.
↧