PDA

View Full Version : Key codes



impeteperry
28th April 2006, 02:02
Hi.
I'm using Qt-4.1.2 and Qt-Desigper.
Somewere I had a list of keycodes. which I am using in my program.
void edpForm::keyPressEvent( QKeyEvent *k )
{
if( k->key() == 0X01000030 && ui.pb1->isEnabled() ) emit fk1clicked();
if( k->key() == 0X01000031 && ui.pb2->isEnabled() ) emit fk2clicked();
if( k->key() == 0X01000032 && ui.pb3->isEnabled() ) emit fk3clicked();
if( k->key() == 0X01000033 && ui.pb4->isEnabled() ) emit fk4clicked();
if( k->key() == 0X01000034 && ui.pb5->isEnabled() ) emit fk5clicked();
if( k->key() == 0X01000035 && ui.pb6->isEnabled() ) emit fk6clicked();
}
but I can't find the list.

Help would be appreciated

jacek
28th April 2006, 02:28
Here: http://doc.trolltech.com/4.1/qt.html#Key-enum

Your code would be much more readable if you were using key names (like Qt::Key_F1 instead 0x01000030).

impeteperry
28th April 2006, 05:13
Agreed, but what I really needed is the code when the "tab" key is struck. Using the following code
int n = k->key();
ui.errorMessages->setPlainText( "key code = " + h.setNum( n ) ); I can get any of the key codes, but this snippit does not give any number when the tab key is pressed.

I think I can get what I want wiith one of the "focusEvent" functions.

Thanks for your prompt reply.

jacek
28th April 2006, 13:04
I think I can get what I want wiith one of the "focusEvent" functions.
Yes, but the tab key is handled by the widget with focus, so if your form has some child widgets one of them might consume the event before it reaches your form.

impeteperry
28th April 2006, 19:35
Thanks for the help
I think I've got it.