petermlm
petermlm

Reputation: 940

Get mouse position in a QImage

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.

Upvotes: 2

Views: 2025

Answers (1)

TonyK
TonyK

Reputation: 17114

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.)

Upvotes: 6

Related Questions