键盘和鼠标事件透明小部件
当我单击主窗口中的按钮时,我希望它对键盘和鼠标事件变得透明,即所有键盘和鼠标事件都应传递到其下方的任何窗口,就好像该窗口不存在一样。
Qt::WA_TransparentForMouseEvents
在这里不起作用,因为我猜这只会使子窗口对键盘和鼠标事件透明。我的窗口是主窗口,我想将所有事件传递到桌面上的任何窗口而不仅仅是父窗口。
When I click a button my main window I want it to become transparent to keyboard and mouse events, i.e. all keyboard and mouse events should pass to any windows below it as if that window is not present there.
Qt::WA_TransparentForMouseEvents
does not work here as this only make child windows transparent to keyboard and mouse events I guess. And my window is main window and I want to pass all event to any window on desktop not just parent window.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是示例代码,它使我能够进行绘图,并且鼠标事件仍然可以通过它。
Here is the sample code which enables me to do drawing on and still mouse events go through it.
我一直在我的应用程序中使用
Qt::WA_TransparentForMouseEvents
并且效果很好。我不明白你面临的问题,但它应该有效。如果您仍然遇到问题,请将属性设置为
Qt::WA_TransparentForMouseEvents
和Qt::WA_Translucentbackground
。I have been using
Qt::WA_TransparentForMouseEvents
in my application and it works great.I don't understand the problem you are facing but it should work. If you still have problem setattribute to
Qt::WA_TransparentForMouseEvents
andQt::WA_Translucentbackground
.