Results 1 to 9 of 9

Thread: Capture a keyboard event

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Capture a keyboard event

    Can you show your code that is dealing with the key events?
    If you are using ascii() for these keys it wont work since they don't have an ascii() representation, you should use the Qt::Key value.

  2. #2
    Join Date
    Jan 2006
    Posts
    80
    Thanks
    1
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Capture a keyboard event

    Quote Originally Posted by high_flyer
    Can you show your code that is dealing with the key events?
    If you are using ascii() for these keys it wont work since they don't have an ascii() representation, you should use the Qt::Key value.
    I could receive the arrow press event but on enter press nothing is happening except a repeating of
    other events (defined in the code).....

    key_press is my global variable

    void MyWidget::keyPressEvent(QKeyEvent *event)
    {
    if(event->key() == Qt::Key_Up) {
    key_press = -1;
    }am able to
    else if(event->key() == Qt::Key_Down) {
    key_press = 1;
    }am able to
    else if(event->key() == Qt::Key_Enter) {
    key_press = 3; // But this part of the code is not reached on enter key press
    }
    else {
    QWidget::keyPressEvent(event);
    }

    // other events....

    }
    Last edited by mahe2310; 16th February 2006 at 09:19. Reason: fail to include few ogf the statements ...

  3. #3
    Join Date
    Feb 2006
    Posts
    6
    Thanks
    1
    Thanked 4 Times in 1 Post

    Default Re: Capture a keyboard event

    I had a similiar problem a day ago, i posted my solution in the end how to catch Tab, enter and space and so on.

    http://www.qtcentre.org/forum/showthread.php?t=670

  4. #4
    Join Date
    Jan 2006
    Posts
    80
    Thanks
    1
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Capture a keyboard event

    Quote Originally Posted by lumber44
    I had a similiar problem a day ago, i posted my solution in the end how to catch Tab, enter and space and so on.

    http://www.qtcentre.org/forum/showthread.php?t=670

    thanks lumber... That is a good one...

    Mahe2310

Similar Threads

  1. Replies: 4
    Last Post: 19th February 2009, 11:10
  2. Event propagation direction
    By spraff in forum Qt Programming
    Replies: 0
    Last Post: 6th December 2008, 21:03
  3. how to manipulate the keyboard event?
    By Ricardo_arg in forum Qt Programming
    Replies: 2
    Last Post: 4th August 2008, 07:49
  4. On Screen Keyboard Problem
    By cutie.monkey in forum Qt Programming
    Replies: 1
    Last Post: 16th July 2008, 13:28
  5. Qt event queue overloading?
    By gct in forum Qt Programming
    Replies: 3
    Last Post: 17th March 2008, 18:39

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
  •  
Qt is a trademark of The Qt Company.