想在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真好用