PDA

View Full Version : overlaping QGraphicsItem-s hover events



stefan
21st August 2011, 21:39
I have more QGraphicsItems on top of each other. How can I make hover event available for all items? Only the last added item (the one on the top) accepts hover events.

Thanks

wysota
22nd August 2011, 07:05
You can ignore the event in the item. It will then propagate to the item below.

stefan
22nd August 2011, 07:50
I done this, but it's not working. Only top item receives hover event.
Any advice where to look for an error?


void MyItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
drawRuler = true;
update();
event->ignore();
}

wysota
22nd August 2011, 09:38
Probably an item will only receive hoverMoveEvent when it has already accepted hoverEnterEvent. You need to propagate all hover events.

stefan
22nd August 2011, 19:02
Probably an item will only receive hoverMoveEvent when it has already accepted hoverEnterEvent. You need to propagate all hover events.
I already did that. No success..
In documentation it says that ignore has no effect. That's probably the reason why is not working..

Calling QEvent::ignore() or QEvent::accept() on event has no effect.
http://doc.qt.nokia.com/4.7-snapshot/qgraphicsitem.html#hoverEnterEvent