Qt4:使全屏窗口无法绕过(锁定屏幕)?
我的应用程序是一个操作系统锁定屏幕(如 GDM 的锁定屏幕或 KDE 的锁定屏幕),因此我试图使其具有类似的功能。
我试图使我的应用程序的窗口悬停在所有其他窗口上方,并禁用/拦截所有键盘快捷键(ALT-TAB
、CTRL-ALT-D
等)这会导致它消失。
有什么办法可以做到这一点吗?我 100% 肯定有,因为带有 GUI 的锁屏是存在的,但我就是找不到地方可以看......
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.
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.
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不知道如何使用 Qt 做到这一点,但您正在寻找的称为 抓取。您可以抓取指针输入设备以及键盘。
编辑:查看Qt4文档,您是否尝试过使用QWidget::grabMouse?看起来这个函数完全符合你的要求。
I don't know how to do it with Qt, but what you are looking for is called grabbing. 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? It looks like this function does exactly what you want.
我不知道这是否是最好的解决方案,但您可以尝试使用 QObject::installEventFilter() 的事件处理程序。
如果您使用的是 Windows,则可以安装一个事件过滤器来处理
event->type() == QEvent::WinEventAct
的消息。我对其他操作系统了解不多,但 Qt 可能也有这方面的东西。
I don't know if this is the best solution, but you can try an event handler using
QObject::installEventFilter()
.If you are using Windows, you can install an event filter that handles messages where
event->type() == QEvent::WinEventAct
.I don't really know much about other OSs, but Qt probably has something for that too.
继承带有参数
Qt::WindowStaysOnTopHint
的Qwidget
类,见下文inherit
Qwidget
class with parameterQt::WindowStaysOnTopHint
see below