Qt:检测鼠标是否位于某个小部件上,即使该小部件没有焦点
我想检测鼠标是否位于 Qt4.7 中的某个小部件上。这背后的想法是,如果按下某个键并且鼠标位于某个小部件上,则执行操作。我发现鼠标跟踪对此不起作用(特别是因为我使用的是不公开鼠标移动信号的第三方小部件)。另外,即使按下按键时小部件没有焦点,我也需要它才能工作。
我真的很感激任何想法。
提前致谢。
I want to detect if the mouse is over a certain widget in Qt4.7. The idea behind this is to take an action if a certain key is pressed and the mouse is over a certain widget. I've found that mouse tracking is not working for this (in particular because I'm using a third party widget that does not expose the mouse moved signal). Also, I need this to work even if the widget does not have the focus when the key is pressed.
I would really appreciate any idea.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以/必须覆盖
enterEvent
和leaveEvent
虚拟信号。这些可用于跟踪鼠标所在的小部件,即使该小部件没有焦点。There are the
enterEvent
andleaveEvent
virtual signals that you can/must override. These can be used to track which widget the mouse is positioned over, even if the widget does not have focus.