想在Graphics View控件里实现实时显示坐标,于是重写了mouseMoveEvent函数,但发现只有在按住左键或右键时才会触发/响应。后来在帮助文档下看到了:
If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.
在构造函数里加上:
setMouseTracking(true);
第一次发博客,markdown真好用
GraphicsView实时坐标显示
为实现在GraphicsView中实时显示鼠标坐标,通过重写mouseMoveEvent函数并启用鼠标跟踪,即使不按下鼠标按钮也能响应鼠标移动事件。
9189

被折叠的 条评论
为什么被折叠?



