PDA

View Full Version : Something about the QKeyEvent in Qt3



cspp
30th June 2009, 03:21
My Platform is WinXp+VC6.0+Qt3.
I rewrite the QWidget::keyPressEvent(QKeyEvent* e).
but something wrong about it,
if I press the key 'a',the e.key() = 65 and text is 'a',the state = 0,but the ascii is 97; OK
if I press the key 'b',the e.key() = 66 and text is 'b',the state = 0,but the ascii is 98; OK
if I press the key "Ctrl+a",the e.key = 65,and text().ascii()[0] = 1,the stete = 512; Err;
if I press the key "Shift+a",the e.key = 65,and text() = 'A',the ascii = 65;OK

so I want to know why I press the key "Ctrl+a",the text() is not 'a'?and why the key() is always equal to 65 and not equal to 97?

thanks!

nish
30th June 2009, 03:38
so I want to know why I press the key "Ctrl+a",the text() is not 'a'?
open up notepad.. press the key a.... u will see "a" typed on the screen.
now press Ctrl+a... nothing will be typed... u will see selection. thats why the text is not a.


and why the key() is always equal to 65 and not equal to 97?
because key() returns Qt::Key_A (in Qt4... in Qt3 also if i remeber correctly). Qt::Key_A is a enum value
which means the hardware key which can have only one value. In other words Qt::Key_A == "the first key of the second row of keyboard", and the hardware key may represent another charector in chinese.