Qt小笔记

来源:互联网 发布:gps工作原理 知乎 编辑:程序博客网 时间:2024/06/16 15:54
<1>:
setMouseTracking(true);//!设置为true则鼠标不用按下都可以追踪鼠标的坐标,
                       //!设置为false则鼠标按下才可以追踪
以下是文档的说明:
mouseTracking : bool
This property holds whether mouse tracking is enabled for the widget.
If mouse tracking is disabled (the default), the widget only receives mouse move events when at least one mouse button is pressed while the mouse is being moved.
If mouse tracking is enabled, the widget receives mouse move events even if no buttons are pressed.
Access functions:
bool hasMouseTracking() const
void setMouseTracking(bool enable)
<2>:
在QMouseEvent事件中:event->pox().x()与event->globalPos().x()的区别:
    前者是鼠标相对于窗口的坐标,而后者是鼠标相对于整个屏幕的坐标。
原创粉丝点击