简体   繁体   English

获取鼠标在QImage中的位置

[英]Get mouse position in a QImage

I need to get the coordinates of a QImage of where the mouse is currently hovering. 我需要获取鼠标当前悬停的位置的QImage的坐标。 Like in image editing programs, where we can see the coordinates of the pixel the mouse in currently hovering. 就像在图像编辑程序中一样,在这里我们可以看到鼠标当前悬停时像素的坐标。

Call setMouseTracking(true) , and override mouseMoveEvent . 调用setMouseTracking(true)并重写mouseMoveEvent Your mouseMoveEvent function will be called whenever the mouse moves inside the QImage. 每当鼠标在QImage中移动时,都会调用mouseMoveEvent函数。 (You have to create a subclass of QImage to do this.) (您必须创建QImage的子类才能执行此操作。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM