Qt 和 X11 全屏应用程序,同时阻止窗口管理器
我想我需要将 XEvent 与 QMainWindow 一起使用,以使我的应用程序即使通过窗口管理器也无法关闭,任何人都可以提供一个示例吗?
它就像一个全屏视频游戏,它会阻止所有键盘、鼠标按钮。
PS:QWidget::grabKeyboard() &&当我尝试使用“ALT_TAB”等组合键切换到其他应用程序时,QWidget::grabMouse() 不起作用,
谢谢。
i think i need to use a XEvent with QMainWindow together to make my application unable to close even by Window Manager , could any one provide an example ?
It's like a fullscreen video game , which blocks all keyboards , mouse buttons.
P.S: QWidget::grabKeyboard() && QWidget::grabMouse() doesn't work when i try to switch to other applications with key combinations like "ALT_TAB"
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要完全阻止来自其他应用程序的所有输入,您需要使用
XGrabServer
而不是XGrabKeyboard
/XGrabPointer
组合。不知道 Qt 是否有 API,但您始终可以直接调用 Xlib 函数。但我建议不要这样做。如果应用程序由于某种原因没有释放抓取,你就会被卡住,需要逃到控制台来杀死它。
To completely block all inputs from other apps, you need to use
XGrabServer
and notXGrabKeyboard
/XGrabPointer
combination. Dunno whether Qt has an API for that but you can always call the Xlib function directly.I however recommend against it. If the application is for some reason doesn't release the grab, you're stuck and need to escape to the console to kill it.
我认为您可以覆盖主窗口的 closeEvent() 并使用 ignore() 方法拒绝该事件,如此处。
I think you can override closeEvent() of your main window and reject the event by using ignore() method as described here.