简体   繁体   English

Qt4:使全屏 window 无法绕过(锁定屏幕)?

[英]Qt4: Making fullscreen window impossible to get around (a lock screen)?

My application is an OS lock screen (like GDM's lock screen or KDE's), so I'm trying to make it function like one.我的应用程序是一个操作系统锁屏(如 GDM 的锁屏或 KDE 的),所以我试图让它像 function 一样。

I am trying to make my application's window hover above all other windows and disable/intercept all keyboard shortcuts ( ALT-TAB , CTRL-ALT-D , etc.) that would cause it disappear.我正在尝试使我的应用程序的 window hover 高于所有其他 windows 并禁用/拦截所有键盘快捷键( ALT CTRL-ALT-D ALT-TAB ,等),这会导致它消失

Is there any way to do this?有没有办法做到这一点? I'm 100% sure there is, as lock screens with GUIs exist, but I just can't find the place to look...我 100% 肯定有,因为存在带有 GUI 的锁屏,但我就是找不到可以看的地方……

I don't know how to do it with Qt, but what you are looking for is called grabbing .我不知道如何用 Qt 做到这一点,但你正在寻找的是所谓的抓取 You can grab the pointer input device as well as the keyboard .您可以抓住指针输入设备以及键盘

Edit: Looking in to the Qt4 docs, have you tried to use QWidget::grabMouse ?编辑:查看 Qt4 文档,您是否尝试过使用QWidget::grabMouse It looks like this function does exactly what you want.看起来这个 function 完全符合您的要求。

inherit Qwidget class with parameter Qt::WindowStaysOnTopHint see below继承Qwidget class 参数Qt::WindowStaysOnTopHint见下文

myclass::myclass(QWidget *parent) : QWidget(parent,Qt::WindowStaysOnTopHint)

I don't know if this is the best solution, but you can try an event handler using QObject::installEventFilter() .我不知道这是否是最好的解决方案,但您可以尝试使用QObject::installEventFilter()的事件处理程序。

If you are using Windows, you can install an event filter that handles messages where event->type() == QEvent::WinEventAct .如果您使用的是 Windows,您可以安装一个事件过滤器来处理 event- event->type() == QEvent::WinEventAct的消息。

I don't really know much about other OSs, but Qt probably has something for that too.我对其他操作系统不太了解,但 Qt 可能也有一些东西。

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

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