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

Window's active property is always true

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.12.2, 5.12.6, 5.13.1, 5.13.2
    • Fix Version/s: None
    • Labels:
      None
    • Platform/s:
      Windows

      Description

      The change signal for the active property is emitted whenever the window loses/gains focus, but the value of the active property is always true.

       

      Here's a minimal example to reproduce the problem:

       

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtQuick.Controls 2.4ApplicationWindow {
          id: root
          width: 300
          height: 400
          visible: true
          onActiveChanged: {
              console.log("[MainWindow::onActiveChanged]")
              console.log("    active:", active)
          }
          
          Window {
              id: subWindow
              width: 300
              height: 400
              visible: true
              onActiveChanged: {
                  console.log("[SubWindow::onActiveChanged]")
                  console.log("    active:", subWindow.active)
              }
              color: "red"
          }
      }

       

      EDIT:

      I just noticed the comment in qwindow.cpp

      /*!
          Returns \c true if the window should appear active from a style perspective.
          This is the case for the window that has input focus as well as windows
          that are in the same parent / transient parent chain as the focus window.
          To get the window that currently has focus, use QGuiApplication::focusWindow().
      */
      

      So, by that explanation, it's actually working as intended since subWindow'_s transient parent is _root. I can't recall reading that anywhere in the official documentation. Maybe that can be added?

      Also, getting a change signal even though the resulting value is the same seems a bit odd to me. The documentation for Window::requestActivate() says: "Requests the window to be activated, i.e. receive keyboard focus.". But in this example when switched from one window to another, the previous window will obviously lose keyboard focus. But when we check for Window::active it will return true. Maybe I'm missing something about Windows' window API. But it seems confusing to me.

        Attachments

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

          Activity

            People

            • Assignee:
              qt.team.quick.subscriptions Qt Quick and Widgets Team
              Reporter:
              furkanzmc Furkan Üzümcü
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Gerrit Reviews

                There are no open Gerrit changes