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

QKeySequence cannot be sent to QML Shortcut from C++ side

    XMLWordPrintable

Details

    • macOS
    • a4de7389b (dev), 3c7812ce2 (6.5), efd1e2530 (6.6)

    Description

      Reproducer attached. Run it on macOS and there will be a native menu bar coming up. See:
      1. 'Working Hotkeys' whose menu items have shortcuts and can be triggered by key sequences specified on QML side, i.e., 'Ctrl + A' and 'StandardKey.Copy'. Pressing shortcut keys makes console output something.
      2. 'Not Working' whose menu item also has shortcut but CANNOT be triggered by key sequences passed from C++ side. Although it is still 'QKeySequence::Print', i.e., a QKeySequence::StandardKey. In fact, other QKeySequences does not either, e.g., QKeySequence(Qt::CTRL | Qt::Key_P).
      If

      Component.onCompleted {
          console.log(shortcut)
      } 
      

      is added to MenuItem 'C', i.e., the not working one, actually we can see that the shortcut is sent and recognized since console outputs macOS command followed by P. So the title is probably not very accurate. The shortcut key sequence is sent, recognized, but not triggered.

      A guess is that the reason lies in QQuickLabsPlatformMenuItem::sync() where m_shortcut may or may not be correctly converted.

      If aforementioned use case 2 is not how shortcut should work and it is not a bug, then probably documentation needs some revision.

      Attachments

        For Gerrit Dashboard: QTBUG-113743
        # Subject Branch Project Status CR V

        Activity

          People

            sami.shalayel Sami Shalayel
            luqiaochen Luqiao Chen
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes