0

How to assign a QShortcut QkeySequence based on user-selected languages. For example, In my case, I select "Tamil" as my Language selection. And I Use the "Tamil99" keyboard layout for input. According to the "Tamil99 keyboard layout" , "Key_A" corresponds to "அ" . My key Sequence is "Alt+அ". How to achieve it?

#mykey = QShortcut(QKeySequence(Alt+அ), self)
mykey = QShortcut(QKeySequence(Alt+A), self)
mykey.activated.connect(self.func_keysequence_process)
tckraomuqnt
  • 470
  • 4
  • 17
  • 1
    This post may answer your question: https://stackoverflow.com/questions/71370107/how-to-change-input-keyboard-layout-programmatically-in-pyqt5 – dsillman2000 Jun 21 '22 at 15:58
  • 1
    Can't you use a simple dictionary that uses tamil characters as keys and the latin counterpart for values? `keyDict = {'அ': 'a', ...}` then just use string replacement (or, better, `re.sub`) to substitute the tamil characters. – musicamante Jun 21 '22 at 16:46
  • 1
    Key sequences are (or should be) translatable strings. If you're serious about handling multiple languages, you should think about making use of [Qt's Internationalisation Support](https://doc.qt.io/qt-5/internationalization.html). (See also: [Keyboard Layout Issues](https://doc.qt.io/qt-5/qkeysequence.html#keyboard-layout-issues)). – ekhumoro Jun 21 '22 at 21:32

0 Answers0