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

When a Dialog is hidden then it is possible that it does not reset the focus correctly if when it loses active focus it does the process again to hide the dialog

    XMLWordPrintable

Details

    • 1a5a0a591c35dcf498a232a802087683f2244ecb + 59aaf903cc54a7cfba00ec3859ca59292f4cbf4a (qt/qtquickcontrols2/dev) ef7290de7be9d36fc590956a32444bb8b1db384c + b0b11a6d4ae8a03998a5c84b91d9cb0b75387059 (qt/qtquickcontrols2/5.15)

    Description

      When a Dialog is hidden then it is possible that it does not reset the focus correctly if when it loses active focus it does the process again to hide the dialog. What happens is the following:

      • Dialog has visible set to false due to some interaction (such as a key press)
      • Dialog then clears the active focus
      • The loss of active focus causes the application to hide the dialog again
      • This causes it to not correctly reset the focus to the item expected (since it reenters the exit transition)

      In the example, to reproduce, press the left key twice to show and then hide the dialog. Then press a key and it will not show up any output.

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtQuick.Controls 2.5
      
      ApplicationWindow {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          Rectangle {
              id: defaultItem
              anchors.fill: parent
              focus: true
      
              Keys.onLeftPressed: dialog1.visible = !dialog1.visible
              Keys.onRightPressed: dialog2.visible = !dialog2.visible
              Keys.onPressed: console.log("key pressed!")
          }
      
          Dialog {
              id: dialog1
              focus: true
      
              contentItem: Text {
                  focus: true
                  text: "dialog 1"
                  Keys.forwardTo: [defaultItem]
              }
              onActiveFocusChanged: {
                  console.log("activeFocus changed="+activeFocus+"-visible="+visible)
                  if (!activeFocus)
                      visible = false
              }
          }
      
      
          Dialog {
              id: dialog2
              x: 40
              focus: true
      
              contentItem: Text {
                  focus: true
                  text: "dialog 2"
                  Keys.forwardTo: [defaultItem]
              }
          }
      }
      

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            andysh Andy Shaw
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: