I'm stuck on how to approach this. I have a QGraphicsItem within a scene, and I'm passing a hover event from the scene to this child. While the move event occurs (I'm just using mouseMoveEvent with mouse tracking on), I want another QGraphicsItem to follow the cursor.
I don't need any collision detection, drag and drop, etc. Just an item that follows the cursor. The only two ways I can think of are...
I'm probably either overthinking this or unaware of another way to do this... any suggestions?
I did it like this
cursor
which will be moved with mouse-cursor, and store its pointer somewhere (in scene subclass for instance. I have a toolset, so for me it's in one of these tools)QGraphicsItem::setZValue
) so that the cursor will be painted above all other items in your sceneQGraphicsScene::mouseMoveEvent
events, forward these events down to the cursor
pointer, and update item's positionthat's it. I guess it corresponds to your solution 1, except you don't have to clear the scene thanks to z-value feature.