Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with dead keys

Problem with dead keys

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 1.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    james rogers
    wrote on last edited by james rogers
    #1

    Hi all,

    I want to detect the keyboard button press for the '^' dead key on the French/France layout. However, I get the Qt::Key_unknown code provided in the overriden keyPressEvent(QKeyEvent *keyEvent) or eventFilter(QObject *obj, QEvent *event) methods. This issue only occurs for me in macOS High Sierra. Windows 10 correctly recognises the key and gives me the Qt::Key_AsciiCircum code.

    Any idea why I am getting these results?

    As a side note, Qt correctly registers the '^' key independently, and the '^' + 'i' key combination to form the î in a text edit. So it is obviously recognising the key - just not in the keyPressEvent(QKeyEvent *keyEvent) or the eventFilter(QObject *obj, QEvent *event) methods.

    I am running Qt 5.9.3 for Windows 10, and 5.9.2 for mac OS High Sierra.

    Thanks

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      Not sure its the same we we had issues with MacOS+ parallels running a linux.
      We had to add the keys to the linux to make the Apple keyboard work. ( Qt Creator)
      Also he changed layout in MacOS. ( im on windows/linux so didnt pay super attention)

      Something like this
      https://superuser.com/questions/403508/how-to-reproduce-the-behavior-of-mac-os-xs-dead-keys-on-windows-7

      Sorry I dont have the exact details at hand.

      J 1 Reply Last reply
      2
      • mrjjM mrjj

        Hi
        Not sure its the same we we had issues with MacOS+ parallels running a linux.
        We had to add the keys to the linux to make the Apple keyboard work. ( Qt Creator)
        Also he changed layout in MacOS. ( im on windows/linux so didnt pay super attention)

        Something like this
        https://superuser.com/questions/403508/how-to-reproduce-the-behavior-of-mac-os-xs-dead-keys-on-windows-7

        Sorry I dont have the exact details at hand.

        J Offline
        J Offline
        james rogers
        wrote on last edited by
        #3

        @mrjj Qt recognises the dead keys in a textEdit widget. It just has trouble picking them up in the keyPressEvent(QKeyEvent *keyEvent) or eventFilter(QObject *obj, QEvent *event) methods of QWindow. That would mean the keys are correctly working right?

        mrjjM 1 Reply Last reply
        1
        • J james rogers

          @mrjj Qt recognises the dead keys in a textEdit widget. It just has trouble picking them up in the keyPressEvent(QKeyEvent *keyEvent) or eventFilter(QObject *obj, QEvent *event) methods of QWindow. That would mean the keys are correctly working right?

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi
          Yes that sounds like its related to native widgets.
          I never used a QWindow but i wonder if it would work with
          http://doc.qt.io/qt-5/qabstractnativeeventfilter.html#details

          J 1 Reply Last reply
          3
          • J Offline
            J Offline
            james rogers
            wrote on last edited by
            #5
            This post is deleted!
            1 Reply Last reply
            0
            • mrjjM mrjj

              Hi
              Yes that sounds like its related to native widgets.
              I never used a QWindow but i wonder if it would work with
              http://doc.qt.io/qt-5/qabstractnativeeventfilter.html#details

              J Offline
              J Offline
              james rogers
              wrote on last edited by
              #6

              @mrjj That works perfectly. The event didn't give me the key character, just the physical key code. It was up to me to manually assign the characters to the key code. However, this solved my problem and I can now detect individual dead key presses.

              bool CocoaNativeEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *)
              {
                  if (eventType == "mac_generic_NSEvent") {
                      NSEvent *event = static_cast<NSEvent *>(message);
                      if ([event type] == NSEventKeyTypeDown) {
              
                          // Handle key event
                         unsigned int key = [event keyCode];
                      }
                  }
                  return false;
              }
              
              1 Reply Last reply
              2

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved