Solved 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 overridenkeyPressEvent(QKeyEvent *keyEvent)
oreventFilter(QObject *obj, QEvent *event)
methods. This issue only occurs for me in macOS High Sierra. Windows 10 correctly recognises the key and gives me theQt::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 theeventFilter(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
-
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-7Sorry 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 thekeyPressEvent(QKeyEvent *keyEvent)
oreventFilter(QObject *obj, QEvent *event)
methods ofQWindow
. That would mean the keys are correctly working right? -
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 -
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; }