0

I have a strange problem with Text Input and Qt. I have a Widget that takes Key Press events, extracts the text and appends the text to a string variable and then creates a QTextDocument in the paint event and paints the text, so far so good, works with Latin letters. But when some users try to type non Latin letters like Russian, then some letters are are still in Latin and others are missing totally.

For example, typing this text: "Не работает на русском языке" results in this: enter image description here

I'm getting the typed letters from QKeyEvent https://doc.qt.io/qt-5/qkeyevent.html#text

Any idea what causes this behavior and how to fix it?

Damir Porobic
  • 681
  • 1
  • 8
  • 21
  • The document encoding perhaps? Some part of your process seems to be ignoring some/all extended characters, or something like that. I'm not sure it will be possible to diagnose without seeing code or a reproducible example. Perhaps compare what you're getting in your inputs to the same keys being pressed in one of the Qt text editor widgets, and then trace the differences. – Maxim Paperno Sep 01 '19 at 01:52
  • It looks like my shortcut filter is causing this issue. In my application I have some keyboard shortcuts that I must ignore while I'm entering text so I've added a eventFilter that captures shortcuts and creates normal keyPressEvents from them and post them, works fine with Latin Characters but not with other. Here is the event filter: https://github.com/DamirPorobic/kImageAnnotator/blob/master/src/common/filter/IgnoreShortcutsFilter.cpp Is there any betters solution for this? Something like https://wiki.qt.io/ShortcutOverride but usable on custom widgets? – Damir Porobic Sep 02 '19 at 10:28
  • This seems to be the solution: https://stackoverflow.com/questions/44914888/qt-override-widget-shortcut-window-shortcut – Damir Porobic Sep 02 '19 at 10:54

0 Answers0