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

南笙酒味 提交于 2019-12-02 07:13:38

问题


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...


回答1:


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.




回答2:


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.




回答3:


inherit Qwidget class with parameter Qt::WindowStaysOnTopHint see below

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


来源:https://stackoverflow.com/questions/6793728/qt4-making-fullscreen-window-impossible-to-get-around-a-lock-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!