Details
Description
If you have a QWidgetAction in a menu in the menubar on OS X, when that action is displayed (you don't have to select the action, or even roll over it) the currently active window is de-activated. But when the QWidgetAction is hidden, the window is not re-activated, leaving the window in a strange state.
I have attached a project that illustrates the problem. The application shows two instances of a subclass QMainWindow, each with a QLineEdit and a QPlainTextEdit. The subclass overrides QMainWindow::event() to intercept QEvent::WindowActivated and QEvent::WindowDeactivated events; it logs a line into the appropriate QPlainTextEdit to show the activation/deactivation history of the two windows.
Run the application. With First Window as the active window, pull down the TEST menu. As you roll down the menu, you will first roll over a normal menu item. Next you will roll over an item that activates a submenu; that submenu contains a QWidgetAction. Note that as the submenu is displayed, First Window logs a Deactivate event.
Type ESC or click in First Window to dismiss the menu.
Now the window is in a strange state- the title bar appears active, but neither the QLineEdit nor the QPlainTextEdit have a blinking caret. If you drag over text in either widget, it will select the dragged text, but highlights it in the gray inactive selection color.
Now click in Second Window. Second Window gets a WindowActivate event, but First Window gets nothing.
Now click in First Window. First Window gets a WindowActivate event and Second Window gets a WindowDeactivate event. Now First Window acts normally.
In our real application where I discovered this bug, the same QWidgetAction in a contextual menu does not cause this problem.