Tomasito665

QKeyEvent::key() returns same for key W and S on Greek kbd

Aug 10th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. // Let's say that these QKeyEvents are respectively
  2. // an event triggered by a Greek keyboard pressing
  3. // the W key and the S key (without any modifiers)
  4. QKeyEvent *w, *s;
  5.  
  6. // Then we convert the key to a QKeySequence (we said
  7. // here above that there were no modifiers, so we are
  8. // not keeping out any info in this particular case by
  9. // only looking at QKeyEvent::key())
  10. QKeySequence keyseq_w = QKeySequence(w->key());
  11. QKeySequence keyseq_s = QKeySequence(s->key());
  12.  
  13. // Although two physically different keys were pressed,
  14. // QKeyEvent::key() returns 931 for both the W key as
  15. // the S key.
  16. //
  17. // This has to do with the fact that both keys are
  18. // holding sigma...
  19. // W => ς, Σ (lower-case in word-final positin, upper-case)
  20. // S => σ, Σ (lower-case, upper-case)
  21. // See wiki on Sigma: https://en.wikipedia.org/wiki/Sigma
  22. //
  23. // ... and that QKeyEvent::key() does not distinguish
  24. // between capital and non-capital letters.
  25. // See documentation: http://doc.qt.io/qt-4.8/qkeyevent.html#key
  26. w->key() == s->key(); // True (see comment for why this is true)
  27.  
  28. // True because both are constructed with the same key
  29. // code (931) and thus are identical QKeySequences
  30. keyseq_w == keyseq_s;
Advertisement
Add Comment
Please, Sign In to add comment