Qt:检测鼠标是否位于某个小部件上,即使该小部件没有焦点

发布于 2024-12-22 05:16:55 字数 171 浏览 1 评论 0原文

我想检测鼠标是否位于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

々眼睛长脚气 2024-12-29 05:16:55

您可以/必须覆盖 enterEventleaveEvent 虚拟信号。这些可用于跟踪鼠标所在的小部件,即使该小部件没有焦点。

There are the enterEvent and leaveEvent 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文