Your calculations are wrong:

Qt Code:
  1. //a-z
  2. if (keyname[0].unicode() >= 'a' && keyname[0].unicode() <= 'z')
  3. return (Qt::Key)(Qt::Key_A + keyname[0].unicode() - 'a');
To copy to clipboard, switch view to plain text mode 

it equals, for the a, to (dec) 65 + 97 - 65 == 97 == "A"

Qt Code:
  1. //A-Z
  2. if (keyname[0].unicode() >= 'A' && keyname[0].unicode() <= 'Z')
  3. return (Qt::Key)(Qt::Key_A + keyname[0].unicode() - 'A');
To copy to clipboard, switch view to plain text mode 
for the a, it's 65 + 97 - 65 == 97 == "a"

also why don't You use this for the a-Z0-9?
Qt Code:
  1. return (Qt::Key)keyname[0].unicode();
To copy to clipboard, switch view to plain text mode