Results 1 to 5 of 5

Thread: QGraphicsView, QScene and keyboard

  1. #1
    Join Date
    Aug 2010
    Posts
    62
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphicsView, QScene and keyboard

    Hello!

    I have a QGraphicsView to which I connected a QScene. Now I'd like to intercept key pressed events on my QGraphicsView but there aren't SIGNALS allowing that...what are the functions to do so?

    Thanks

  2. #2
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: QGraphicsView, QScene and keyboard

    QGraphicsView::keyPressEvent() is what you want.

    So, subclass QGraphicsView and override keyPressEvent().
    Last edited by Urthas; 20th August 2010 at 17:18.

  3. #3
    Join Date
    Aug 2010
    Posts
    62
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsView, QScene and keyboard

    Thanks for the response.
    But how can I recognise the pressed key? In keyPressedEvent there isn't a returned key code which enables me to handle the event...

  4. #4
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: QGraphicsView, QScene and keyboard

    The parameter to QGraphicsView::keyPressEvent() is of type QKeyEvent, which has a function called key(). See Qt::Key for the list of keyboard codes.

  5. #5
    Join Date
    Aug 2010
    Posts
    62
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsView, QScene and keyboard

    ok, thanks a lot! I've found all I need for my program

Similar Threads

  1. Replies: 3
    Last Post: 9th March 2010, 09:37
  2. QListView keyboard nav
    By jej in forum Newbie
    Replies: 0
    Last Post: 11th June 2009, 09:18
  3. Keyboard Hit
    By anu0050 in forum Newbie
    Replies: 1
    Last Post: 2nd May 2007, 14:55
  4. Keyboard Hit
    By anu0050 in forum Qt Programming
    Replies: 1
    Last Post: 2nd May 2007, 12:28
  5. QTextEdit Keyboard (Tab)
    By cristiano in forum Qt Programming
    Replies: 1
    Last Post: 10th February 2007, 16:21

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.