Results 1 to 5 of 5

Thread: Mouse event on a QGraphicsItem that is not in it's own class

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Dec 2012
    Posts
    90
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    5
    Thanked 20 Times in 18 Posts

    Default Re: Mouse event on a QGraphicsItem that is not in it's own class

    I can think of one way of doing so without subclassing. You may create class that will be filtering mouse events and install it on the QGraphicsView via QObject::installEventFilter,
    (you can't install it onto item itself, because it is not derived from QObject). But if you go this way you will be forced to map coordinates from view to item.

    IMHO subclassing QGraphicsRectItem is much more clearer and easy way. It's not that hard! You'll need to override just a few protected methods.

  2. The following user says thank you to lanz for this useful post:

    xzyerasu (28th December 2012)

Similar Threads

  1. Ogre+qt mouse event (add object with mouse problem)
    By rimie23 in forum Qt Programming
    Replies: 7
    Last Post: 24th April 2012, 10:49
  2. Replies: 3
    Last Post: 7th January 2012, 08:38
  3. QGraphicsItem can't receive mouse leave/enter event
    By wshn13 in forum Qt Programming
    Replies: 1
    Last Post: 22nd June 2011, 08:32
  4. Do the layout class can receive the mouse event?
    By tszzp in forum Qt Programming
    Replies: 3
    Last Post: 23rd December 2009, 08:07
  5. can not get mouse double click event for QGraphicsItem
    By learning_qt in forum Qt Programming
    Replies: 2
    Last Post: 14th September 2009, 20:36

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.