0

I custom my own item, which inherits from QGraphicsItem, override the mousePressEvent function, then I add it into QGraphicScene.

When I debug, I move mouse onto my item, then press down, I find that the QGraphicScene's event processing function is called first(I install a event processing filter on QGraphicScene), then mousePressEvent of my custom item is called, is this correct?

How can I made my custom item earlier receiver than QGraphicScene?

user497032
  • 75
  • 1
  • 10

1 Answers1

0

The behavior you describe is correct and by design. The item will never receive the event before the scene does; it is - after all - the scene's job to route the event to the correct item. The scene maintains spatial index of the items and uses it to route the event. What you can do instead is to filter the event on the item itself, not on the scene: use QGraphicsItem::installSceneEventFilter.

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313