1

I'm attempting to build a virtual keyboard using QT Embedded. I'm using QWSServer::sendKeyEvent() to send a key press which expects the unicode value of the key. Is there an easy way of converting from a string ("A" for example) to its key press value?

Thanks

Xleedos
  • 948
  • 2
  • 9
  • 17
  • 1
    unicode value of the key is just `QChar`, you can get it form string like `str.at(0)` – Lol4t0 Feb 12 '12 at 15:47
  • Thanks for your comment, I think i'm getting confused. `void QWSServer::sendKeyEvent ( int unicode, int keycode, Qt::KeyboardModifiers modifers, bool isPress, bool autoRepeat )` The Sendkeyevent expects both a unicode value (as an integer) and its keycode (also an integer) are they not the same thing? Thanks again – Xleedos Feb 12 '12 at 16:01
  • 1
    No, they keycodes are defined at http://doc.qt.nokia.com/4.7/qt.html#Key-enum. Unfortunately they don't directly map to unicode values, you will probably need to create a conversion table. – Dan Milburn Feb 12 '12 at 16:09
  • Thank You Dan, that was what I was afraid of. – Xleedos Feb 12 '12 at 16:11
  • Don't mix `unicode` and `keycode` params. I actually didn't try `WSServer`'s function, but seems close `QKeyEvent` also allows separate `key` & `text` params and setting `text` leaving `key` and etc empty worked perfectly. – Lol4t0 Feb 12 '12 at 16:20

0 Answers0