how to accept event in two objects simultaneously?
My question is: How to accept press/move/release event in two QGraphicsPixmapItem's that are stacked one on another. In top item I need to catch press/release signal to trigger some acction, and in bottom item I need to catch press/move signal to actually move top item.
If I set event->accept in top item, the bottom one does not receive anything, and if I don't, the bottom item has the event but the top item does not receive anything.
Is it possible to have press/move/release event propagade to two item's simultaneously?
I'm using Qt 5.3 at the moment.
If you call QEvent::ignore() in the top item it should be propagated to the other, but you still can do something in the top item (even if you call ignore()).
It doesn't solve my problem.
I mean sure I can do something in mousePressEvent before I actually call event->ignore, but after I call ignore this event (move/release) is not propagated to top item any more.
hi , if you want them to be move as a group , maybe you can use
setParentItem to make sure it happens ?
trying to share events will be messy.
I'm doing just that, items on top are childs of bottom item and when bottom item moves so the children do. The trouble is that I want:
- Short click on top item - item emits signal on mouseRelease
- mouse press and move (on top item) signal is delivered to bottom item, and bottom item moves from left to right (top items also move as they are childrens).
I will have to try different approach, which is: get mouse move coordinates from QGraphicsScene and then decide which item to move on the scene.