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

Alt key modifier behaves erratically when ApplicationWindow menuBar is set

    XMLWordPrintable

Details

    Description

      When running following example on Windows 10:

      in Qt 5.9.5:
      Rectangle loses activeFocus after pressing Alt 2 times.
      Rectangle loses activeFocus after second Alt-Tab switch app back and forth and pressing any key

      In Qt 5.10.1:
      No key event with Alt-modifier is received

      These problems are not present if there's no menuBar property defined.

      import QtQuick 2.9
      import QtQuick.Window 2.2
      import QtQuick.Controls 1.3
      
      ApplicationWindow {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          menuBar: MenuBar {
              Menu {
                  title: "Edit"
              }
          }
      
          Rectangle {
              id: content
              anchors.fill: parent;
              focus: true
      
              onActiveFocusChanged: {
                  console.log("activeFocus: " + activeFocus);
              }
      
              property int keyboardModifiers : 0
      
              Keys.onPressed: {
                  console.log( "pressed key: " + event.key );
                  keyboardModifiers = event.modifiers;
              }
      
              Keys.onReleased : {
                  keyboardModifiers = event.modifiers;
              }
      
              function printModifiers( modifiers ) {
                  switch( modifiers ) {
                  case Qt.ShiftModifier:
                      return "Shift";
                  case Qt.ControlModifier:
                      return "Control";
                  case Qt.AltModifier:
                      return "Alt";
                  case Qt.MetaModifier:
                      return "Meta";
                  default:
                      return "No modifier";
                  }
              }
      
              Text {
                  text: content.printModifiers( content.keyboardModifiers )
                  anchors.centerIn: parent
              }
          }
      }
      

      Attachments

        Issue Links

          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
              pavol.markovic Pavol Markovic
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes