问题
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