Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-76446

FocusIn not delivered at startup

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important 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.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            dmik Dmitriy Kuminov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes