简体   繁体   English

当鼠标在app窗口之外时,QQuickItem在使用grabMouse()后没有接收到鼠标事件

[英]QQuickItem not receiving mouse events after using grabMouse() when mouse is outside app window

I have an QtGuiApplication with single QQuickItem. 我有一个QtGuiApplication和单个QQuickItem。 and I want quickitem to receive mouse events when mouse pointer is outside the Main Window. 当鼠标指针在主窗口之外时,我想要quickitem接收鼠标事件。 mouse pointer can be anywhere in screen. 鼠标指针可以在屏幕的任何位置。 So at the end QQuickItem should receive mouse events(eg mouse move) when the mouse pointer is outside application window. 因此,当鼠标指针位于应用程序窗口之外时,QQuickItem应该接收鼠标事件(例如鼠标移动)。

I used grabMouse [void QQuickItem::grabMouse()] to do this. 我使用了grabMouse [void QQuickItem :: grabMouse()]来做到这一点。 but I see no effect as desired. 但我觉得没有效果。 QuickItem receives event only when mouse pointer is inside App window. 仅当鼠标指针位于App窗口内时,QuickItem才会接收事件。 It stopped getting any mouse event as soon as mouse pointer leaves the QGuiApplication boundary. 一旦鼠标指针离开QGuiApplication边界,它就会停止获取任何鼠标事件。

As I read grabMouse should solve my problem but somehow it doesn't. 当我读到grabMouse应该解决我的问题,但不知何故它没有。 Can anyone point me that is there is any extras need to be done or anything wrong here. 任何人都可以指出我需要做任何额外的事情或这里有什么不妥。

Note : after using grabmouse Quickitem starts getting mousemove event when mouse is passed over application 注意:使用grabmouse后,当鼠标通过应用程序时,Quickitem开始获取mousemove事件

I believe you can not receive mouse events when mouse it outside your application window. 我相信当你将鼠标放在应用程序窗口之外时,你无法接收鼠标事件。 That is how OS usually works. 这就是OS通常的工作方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM