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

Qt Quick1: ActiveFocus is not set correctly when application is not active

    XMLWordPrintable

Details

    Description

      • Run qml code below.
      • Click mouse on application, rect is enabled (changes to green) and gets activefocus.
      • Wait and see that rect is disabled (after 3 sec changes to black) and see from console log that activeFocusChanged signal is emitted. That's correct behavior.
      • Then click application again, rect is enabled
      • Click OTHER application and wait 3sec. See the log that timer triggers. Issue is that activeFocusChanged signal is missing and rect stays green.
      main.qml
      import QtQuick 1.1
      
      FocusScope {
          width: 360
          height: 360
          id: root
      
          Rectangle {
              id: rect
              anchors.centerIn: parent
              height: 60
              width: 60
              color: activeFocus? "green" : "black"
              onActiveFocusChanged:
                  console.log("rect.onActiveFocusChanged: " + rect.activeFocus)
              onEnabledChanged:
                  console.log("rect.onEnabledChanged: " + rect.enabled)
              onFocusChanged:
                  console.log("rect.onFocusChanged: " + rect.focus)
              onVisibleChanged:
                  console.log("rect.onVisibleChanged: " + rect.visible)
          }
      
          Timer {
              id: timer
              interval: 3000
              repeat: false
              onTriggered: {
                  console.log("..timer triggered")
                  console.log("root.activeFocus: " + root.activeFocus)
                  console.log("rect.activeFocus: " + rect.activeFocus)
                  rect.enabled = false
              }
          }
      
          onActiveFocusChanged: {
              console.log("root.onActiveFocusChanged: " + root.activeFocus)
          }
      
          MouseArea {
              anchors.fill: parent
              onClicked: {
                  console.log("root.activeFocus: " + root.activeFocus)
                  console.log("rect.activeFocus: " + rect.activeFocus)
                  rect.enabled = true
                  rect.forceActiveFocus()
                  timer.start()
                  console.log("Timer started..")
              }
          }
      }
      

      Attachments

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

        Activity

          People

            aalpert Alan Alpert
            qtcomsupport Qt Support
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes