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

macOS: QKeySequence from string not working for arrow keys

    XMLWordPrintable

Details

    • macOS

    Description

      On macOS, if you use QKeyPressEvent, you will get "Num↑" etc. if you press an arrow key, using:

      QString keyName = QKeySequence(keyEvent->key() | keyEvent->modifiers()).toString(QKeySequence::NativeText);
      qDebug() << keyName; // Prints "Num↑", "Num↓", "Num←", "Num→" for the arrow keys

      But if you reverse this and try to get QKeySequence using the string, you'll always get Qt::Key_unknown for all 4 arrow keys ("Num↑", "Num↓", "Num←", "Num→").

      const QKeySequence seq(keyName);
      if (seq.count() >= 1)
          qDebug() << seq[0]; // prints 3355443 which is Qt::Key_unknown, for "Num↑", "Num↓", "Num←", "Num→"

      I would expect different numbers for the 4 keyNames.
      The keyEvent::key() for the arrow keys returns Qt::Key_Left, Qt::Key_Right, Qt::Key_Up and Qt::Key_Down.

      Since we are using non-commercial versions of Qt, please let me know if this was fixed in Qt 6. 

      Attachments

        Issue Links

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

          Activity

            People

              vestbo Tor Arne Vestbø
              megamouse Patrick Waldner
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes