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

QtQuick: closing Popup does not restore original focus, breaks Keys.onBackPressed usage



    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Cannot Reproduce
    • Affects Version/s: 5.7.1, 5.8.0
    • Fix Version/s: 5.9.6
    • Component/s: Quick: Controls 2
    • Labels:
    • Environment:
      Android 4.4, 7.1.1
      Qt from online installer,
      Android SDK Tools 25.2.5


      My application uses Keys.onBackPressed to override Android back button press to use it for manual navigation through pages.

      I discovered that after using Popup with focused TextField, most parent component (StackView in my case) does not receive Keys.onBackPressed after Popup is closed and so the app quits.

      When using TextField not in Popup, pressing HW back button works as excepted - first it closes on-screen keyboard, and for the second press Keys.onBackPressed is handled that allows to handle navigation and exit that specific page.

      I have attached example application where you can see two use cases - "simple" TextField with activeFocuse and TextField in Popup with activeFocus.

      Workaround is to uncomment line //onClosed: mainStack.forceActiveFocus(), i.e. manually fix focus. If this is by design, it means I can expect losing focus "anywhere" in the future of app development and makes managing keyboard navigation more explicit and complicated.


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



            • Assignee:
              qt.team.quick.subscriptions Qt Quick and Widgets Team
              talkless Vincas Dargis
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created:

                Gerrit Reviews

                There are no open Gerrit changes