I have a scene with some items, when I click in the view/scene I want to perform some operations, like draw with the mouse etc., but when I click on an item I want to do stuff with that item. Problem is when I click near the edges of an item. The event is handled by both the item and my custom event handler.

In my subclassed scene code i have(pseudo)
Qt Code:
  1. mousePressed(event)
  2. {
  3. // send events to items
  4. QGraphicsScene::mousePressed(event);
  5. if(event->isAccepted())
  6. {
  7. return;
  8. }
  9. // send event to active state
  10. emit(myMousePressed(event));
  11. }
To copy to clipboard, switch view to plain text mode 

I'm fairly new to qt so maybe I've designed the custom event handler in a bad way.

The way it's done is by a somewhat modified state pattern. I have some state classes that connects to the custom event signals. The active state object is determined by a setState in the graphicsscene subclass. When state A is active, A's code for e.g left mouse press is run. By doing it this way a massive switch/case is avoided.

But again, it's the events which reach both items and my event handler that causes the trouble

Any ideas or comments?