-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.12.0
-
None
This happens because QApplication::setActiveWindow does not call Widget::setFocus on hidden widgets. I find this wrong because the latter is specifically designed to receive focus in such cases (it will delay sending the FocusIn event until shown). Therefore, there is no reason to not call it in such cases.
Affected platforms are those which get system FocusIn events for their native top-level windows (delivered to Qt via QWindowSystemInterface::handleWindowActivated) before the window is shown. One case of a failing application is the standard textedit example. In this example, QTextEdit has keyboard focus by default (at startup). However, although keyboard input will go there indeed, the I-beam cursor will not flash until the window is clicked inside the QTextEdit area or deactivated and then activated again (which will trigger FocusIn because QTextEdit is visible already). This is because the flash timer is only started in QTextEditControl upon FocusIn arrival.
I can only test it on OS/2 ATM but I suppose Windows is also affected (since native event handling is very similar there).
The fix is trivial, here's the patch: https://github.com/bitwiseworks/qtbase-os2/commit/d6ee036a7f0e61fa33c4b7f2d36c489d5319f5e3
Interesting enough, this bug goes back to Qt 4 days, according to the commit history.