Problem with dead keys

  • 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.


  • Lifetime Qt Champion

    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

    Sorry I dont have the exact details at hand.

  • @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?

  • Lifetime Qt Champion

    Yes that sounds like its related to native widgets.
    I never used a QWindow but i wonder if it would work with

  • This post is deleted!

  • @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;

Log in to reply