当前位置: 代码迷 >> QT开发 >> QMainWindow不响应mouseReleaseEvent事件,该怎么解决
  详细解决方案

QMainWindow不响应mouseReleaseEvent事件,该怎么解决

热度:95   发布时间:2016-04-25 04:43:39.0
QMainWindow不响应mouseReleaseEvent事件
建的一个QMainWindow只能响应mousePressEvent事件,却不能够响应mouseReleaseEvent事件和mouseMoveEvent事件,请问这是怎么回事?

------解决方案--------------------
QMainWindow只能响应mousePressEvent事件,却不能够响应mouseReleaseEvent事件?
这个是不可能的。

mouseMoveEvent是需要将左键按下移动鼠标才有的。
------解决方案--------------------
QWidget

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 )
See also mouseMoveEvent().
------解决方案--------------------
3楼正解。

楼主最好把代码贴出来,分析下。