Results 1 to 3 of 3

Thread: some keys are not working(keyPressEvent)

  1. #1
    Join Date
    Apr 2011
    Location
    Hyderabad
    Posts
    86
    Thanks
    17
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default some keys are not working(keyPressEvent)

    Hi everybody,

    i am developing s/w for embedded device.

    I am trying to catch all the keys and corresponding message display in my application.
    i am able to get all the key event(0,1,2....., A,B,C....., and even special characters keys like right arrow, left arrow, backspace etc).
    But only two keys(CANCEL, and one FUNCTION) i am not able to get. Qt not generate event for these two keys.
    I have tasted it by re-implementing the keyPressEvent, but not getting event for those two keys.
    But these two keys are working fine..... by h/w there is no problem. Only i am not able to get corresponding event
    in my application for those keys.

    I have reimplemented keyPressEvent like this and tested it.

    Qt Code:
    1. void MyWidget::keyPressEvent( QKeyEvent *e )
    2. {
    3. qDebug("Event : key value is : %d",e->key());
    4. }
    To copy to clipboard, switch view to plain text mode 

    I am able to get all the key values except those two keys
    Can you tel me........Where is the problem?

    thanks in advance !!!!

  2. #2
    Join Date
    Jan 2018
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: some keys are not working(keyPressEvent)

    Hi,

    I got the similar issues as well. When I am in the tab (which is inside the MainWindow), I am not able to get keyPressEvent fired for the left/right arrows

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: some keys are not working(keyPressEvent)

    I am not able to get keyPressEvent fired for the left/right arrows
    That's probably because the QTabWidget (or the QTabBar inside it) is eating those events because it has input focus. Those keys are used to move from one tab to the next.

    You can see those events if you install an event filter on the QTabWidget (or probably the QTabBar inside it). If it is the QTabBar that is eating the events, then you can derive your own QTabBar, override the key press event, and create your own behaviour. You can replace the QTabWidget's default tab bar by deriving your own class from QTabWidget and installing it using the QTabWidget::setTabBar() method. Even if you change nothing else, you still need to derive from QTabWidget because setTabBar() is a protected method.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. keyPressevent not working with timer.
    By T1001 in forum Newbie
    Replies: 5
    Last Post: 9th December 2010, 05:55
  2. vertical keypressevent not working on graphicsitem
    By creatio.x in forum Qt Programming
    Replies: 3
    Last Post: 25th December 2009, 12:23
  3. QtableWidget and hot keys
    By sawerset in forum Qt Programming
    Replies: 1
    Last Post: 8th December 2008, 20:29
  4. How to identify Num pad keys
    By sanjayshelke in forum Qt Programming
    Replies: 1
    Last Post: 2nd September 2008, 18:43
  5. Handling of dead keys in keyPressEvent()
    By ghorwin in forum Qt Programming
    Replies: 4
    Last Post: 2nd December 2006, 13:26

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.