mousemove event in QGraphics
I'm trying to make the program do something while mouse moving in my qgraphics scene/view.but it only works for mousePress event. However it also works when I'm moving my mouse outside the scene/view.
here is my code:
void Main::mousePressEvent(QMouseEvent *e) {...}
void Main::mouseMoveEvent(QMouseEvent *e) {...}
Re: mousemove event in QGraphics
mouse move events only occur when a button is pressed by default, you need to setMouseTracking(true) on the view for the move events to generated in the first place, so that it can forward those to the scene.
Alternatively, if you don't need the translation to scene coordinates, you could reimplement the mouseMoveEvent in the view directly rather than in your scene. But in this case, make sure you call the base class QGraphicsView::mouseMoveEvent in your implementation, so that hover events are properly generated for the items in your scene.
Re: mousemove event in QGraphics