Results 1 to 5 of 5

Thread: Key codes

  1. #1
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Key codes

    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.
    Qt Code:
    1. void edpForm::keyPressEvent( QKeyEvent *k )
    2. {
    3. if( k->key() == 0X01000030 && ui.pb1->isEnabled() ) emit fk1clicked();
    4. if( k->key() == 0X01000031 && ui.pb2->isEnabled() ) emit fk2clicked();
    5. if( k->key() == 0X01000032 && ui.pb3->isEnabled() ) emit fk3clicked();
    6. if( k->key() == 0X01000033 && ui.pb4->isEnabled() ) emit fk4clicked();
    7. if( k->key() == 0X01000034 && ui.pb5->isEnabled() ) emit fk5clicked();
    8. if( k->key() == 0X01000035 && ui.pb6->isEnabled() ) emit fk6clicked();
    9. }
    To copy to clipboard, switch view to plain text mode 
    but I can't find the list.

    Help would be appreciated

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Key codes

    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).

  3. #3
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Key codes

    Agreed, but what I really needed is the code when the "tab" key is struck. Using the following code
    Qt Code:
    1. int n = k->key();
    2. ui.errorMessages->setPlainText( "key code = " + h.setNum( n ) );
    To copy to clipboard, switch view to plain text mode 
    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Key codes

    Quote Originally Posted by impeteperry
    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Key codes

    Thanks for the help
    I think I've got it.

Similar Threads

  1. I need greenPhone keyboard codes
    By hgedek in forum Qt for Embedded and Mobile
    Replies: 6
    Last Post: 21st September 2007, 11:00
  2. Algorithms problem of brackets including.
    By luffy27 in forum General Programming
    Replies: 2
    Last Post: 12th April 2007, 01:10
  3. QR codes
    By jcr in forum General Programming
    Replies: 0
    Last Post: 16th May 2006, 05:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.