Results 1 to 6 of 6

Thread: QGraphicsItem keyPressEvent oddness

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Posts
    63
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QGraphicsItem keyPressEvent oddness

    If you mean in focusInEvent, focusOutEvent and keyPressEvent? - then yes.

    In my scene I've also just removed all functions and overrides that may affect focus (mouse event handers etc)...but no joy.

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsItem keyPressEvent oddness

    you dont have to tear apart your code to search for keyevent.
    just put eventFilter() in your main widget. and see where the keys are going

    Qt Code:
    1. qApp->installEventFilter(this);
    2. bool MainWidgetThatContainsGrphViewAndItems::eventFilter(QObject* o,QEvent* e)
    3. {
    4. if(e->type()==QEvent::KeyPress)
    5. {
    6. qWarning()<<"The bad guy which steals the keyevent is"<<o;
    7. }
    8. return false;
    9. }
    To copy to clipboard, switch view to plain text mode 

    easy!!

    edit: do tell us who was stealing.
    Last edited by nish; 3rd June 2009 at 07:36.

  3. The following 2 users say thank you to nish for this useful post:

    jonks (3rd June 2009), Seishin (15th November 2012)

  4. #3
    Join Date
    May 2009
    Posts
    63
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Thumbs up Re: QGraphicsItem keyPressEvent oddness

    Mr Death - that was pure genius!

    I subclassed QGraphicsView and put a keypress handler in there to reset zoom, and forgot to call the base class implementation.

  5. #4
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsItem keyPressEvent oddness

    Quote Originally Posted by MrDeath View Post
    you dont have to tear apart your code to search for keyevent.
    just put eventFilter() in your main widget. and see where the keys are going

    Qt Code:
    1. qApp->installEventFilter(this);
    2. bool MainWidgetThatContainsGrphViewAndItems::eventFilter(QObject* o,QEvent* e)
    3. {
    4. if(e->type()==QEvent::KeyPress)
    5. {
    6. qWarning()<<"The bad guy which steals the keyevent is"<<o;
    7. }
    8. return false;
    9. }
    To copy to clipboard, switch view to plain text mode 

    easy!!

    edit: do tell us who was stealing.
    Just by browsing the thread can teach me a lot even though I don't need it now

    Thanks!

Similar Threads

  1. QGraphicsItem doesn't inherit QObject?
    By xyzt in forum Qt Programming
    Replies: 6
    Last Post: 26th September 2011, 14:59
  2. destruction of QGraphicsItem
    By killkolor in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2009, 10:31
  3. Replies: 1
    Last Post: 25th February 2009, 00:34
  4. keyPressEvent issue
    By oguzy in forum Qt Programming
    Replies: 1
    Last Post: 7th November 2008, 15:39
  5. Snap-to grid on QGraphicsItem
    By hardgeus in forum Qt Programming
    Replies: 9
    Last Post: 28th April 2008, 16:22

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.