PDA

View Full Version : Mouse events on graphicItems



jjkrol
27th May 2011, 16:12
Hello,
I have a graphics scene in a graphics view.
I managed to draw rectangles (QGraphicsRectItems) and lines (QGraphicsLineItems) on the scene, but I encountered another problem:

How can I overwrite mouse events on these (and other) items?

I am quite resistant against writing my own subclasses, because I want to access many items, so it would be quite demanding and (as far as I understand) I should also subclass the QGraphicsScene to accept my items.
In my search for the solution, I came across the eventFilter. However I have read, that I cannot be applied it to QGraphicsItems.

Please, help me clarify the possible solutions for the problem.

mvuori
27th May 2011, 16:33
I don't see how you would need to subclass QGraphicsScene. It should work with any class derived from QGraphicsRectItem or QGraphicsLineItem. You probably have no choice -- and that's how it's supposed to work in C++ and in Qt.