Get mouse position in a QImage

2k Views Asked by At

I need to get the coordinates of a QImage of where the mouse is currently hovering. Like in image editing programs, where we can see the coordinates of the pixel the mouse in currently hovering.

1

There are 1 best solutions below

1
On BEST ANSWER

Call setMouseTracking(true), and override mouseMoveEvent. Your mouseMoveEvent function will be called whenever the mouse moves inside the QImage. (You have to create a subclass of QImage to do this.)