PDA

View Full Version : Handling parent und child events at once.



dentist
2nd April 2010, 04:13
Hi, I'm trying to subclass QGraphicsView and put a QGraphicsScene in it. I found out, that it is very easy to implement moving items in the scene, just by setting item flags. Unfortunately my QGraphicsView class has to deal with the same mouse events as its scene, so the mouse events don't reach the scene, which means I can't move the items anymore. I know, that it's possible to pass an event to the superclass, but I couldn't figure out, how to forward it to a member after processing the parents code. I need something like this:



void mouseDoubleClickEvent (QMouseEvent* event){

if (some_condition) {
// process the QGraphicsView stuff
}else{
// forward the event to the scene
}

}

Lykurg
2nd April 2010, 06:48
I assume you have subclassed QGraphicsScene. Then simply use QGraphicsScene::mouseDoubleClickEvent(event); in your else statement.

dentist
2nd April 2010, 10:06
i don't have subclassed QGraphicsScene. As i said, my class is derived from QGraphicsView and there is a QGraphicsScene as a member in it.

Lykurg
2nd April 2010, 10:55
ok, then install an eventfilter for your scene.