Results 1 to 2 of 2

Thread: top level keyPressEvent

  1. #1
    Join Date
    Jan 2006
    Location
    Maui, Hawaii
    Posts
    120
    Thanks
    65
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default top level keyPressEvent

    I have some buttons with arrow pictures inside a QMainWindow. I would also like to be able to capture keyboard arrow events.

    The problem is when other widgets receive keyboard focus, they capture the keyboard events before they get to QMainWindow::keyPressEvent().

    Is there some kind of top level signal or virtual function I can override to notify my class when an arrow key is pressed?

    I've seen some similar posts, but I want to make sure on this. I don't want to subclass all the widgets in my window so they pass their key events up the hierarchy.

    Thanks for your help!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: top level keyPressEvent

    Install an event filter on the child widgets you wish to intercept events from.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    mhoover (14th September 2010)

Similar Threads

  1. keypressevent
    By djwk in forum Newbie
    Replies: 9
    Last Post: 5th July 2010, 02:12
  2. Getting real key in keyPressEvent
    By EricF in forum Qt Programming
    Replies: 2
    Last Post: 20th March 2008, 14:39
  3. QTreeWidget keyPressEvent
    By hgedek in forum Qt Programming
    Replies: 3
    Last Post: 18th August 2007, 16:33
  4. F2 keyPressEvent Not Capturing
    By Rayven in forum Qt Programming
    Replies: 1
    Last Post: 2nd August 2007, 20:41
  5. Replies: 4
    Last Post: 4th June 2007, 12:07

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.