Keep making a widget as always on top
-
Hello,
So here is my problem: I created a widget and want to make sure it is always on top. If a user change to another window using alt+tab then it doesn't allow him and go back to my widget.
If you ask why i am doing this then i am creating a university test program in which i want to prevent the user from doing anything in the computer such as closing the window or jumping to another window. I learned that i can override CloseEvent to tackle the closing issue but now am I to keep the window on top ?
Ive done the following:
1- create the widget (done)
2- show widget fullscreen (done)
3- exec the widget (done)how can i proceed to keep making it on top ?
My thought is:
- initialize a timer of let's say 10 milliseconds
- signal slot when timeout to a function that set the window on top.
Hence, if the user changed the screen then within when the timer shoots it goes back to my widget so i can accomplished what i want.
This idea works with window handles when I show an image but not a widget. Can i do same thing to widget ?
Please advice
Many thanks
-
"Qt::WindowStaysOnTopHint":http://doc.qt.nokia.com/latest/qt.html#WindowType-enum
-
Thank you. Correct, but if another 'always on top' window is opened after the Qt one, then the new window becomes on top and the Qt one goes to the back. For example, I run my widget and put the WindowStaysOnTopHint then open task manager. In this case task manager will be on top of my widget.
If I want to do it in winapi, then I can re-issue the the 'Always On Top' command which will make my window on top again. <- i don't want to follow this approach for several issues that affects my application.
So I hope I can find a way to re-issue the always on top command in Qt.
Thanks
-
You can use QWidget->activateWindow()
-
Thank you. Now it works as desired if the widget is showing. But doesn't work if the widget in minimized. Can I maximize it if it is minimized ?
Please advice,
Many thanks
-
Got it. Thank you. I used isminimized, and if yes then shownormal() ;