Qt 和 X11 全屏应用程序,同时阻止窗口管理器

发布于 2024-11-14 07:51:57 字数 227 浏览 11 评论 0原文

我想我需要将 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 技术交流群。

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

发布评论

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

评论(2

如果没结果 2024-11-21 07:51:57

要完全阻止来自其他应用程序的所有输入,您需要使用 XGrabServer 而不是 XGrabKeyboard/XGrabPointer 组合。不知道 Qt 是否有 API,但您始终可以直接调用 Xlib 函数。

但我建议不要这样做。如果应用程序由于某种原因没有释放抓取,你就会被卡住,需要逃到控制台来杀死它。

To completely block all inputs from other apps, you need to use XGrabServer and not XGrabKeyboard/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.

三生池水覆流年 2024-11-21 07:51:57

我认为您可以覆盖主窗口的 closeEvent() 并使用 ignore() 方法拒绝该事件,如此处

I think you can override closeEvent() of your main window and reject the event by using ignore() method as described here.

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