PDA

View Full Version : Keep making a widget as always on top



nackasha
22nd October 2011, 02:26
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

Louis

wysota
22nd October 2011, 21:41
What platform are we talking about?

nackasha
22nd October 2011, 23:48
I am working on Windows XP. Qt 4.7.4.

Many thanks,

Louis

wysota
23rd October 2011, 10:24
In that case I have no idea. Qt won't help you with this anyway, you need to look for native solutions for kiosk mode.

http://www.google.com/search?q=kiosk+Windows

john_god
23rd October 2011, 20:25
I also have no ideia, but what about if you try event filters to cath Alt-Tab and or losefocus event to try to prevent losing focus ?

ChrisW67
24th October 2011, 02:07
Is Qt::WindowStaysOnTopHint ignored by Windows?

nish
24th October 2011, 11:19
Is Qt::WindowStaysOnTopHint ignored by Windows?
no. but they can be minimized/moved/hide behind other stay on top windows.

nackasha
24th October 2011, 14:11
Is Qt::WindowStaysOnTopHint ignored by Windows?


No its not ignored, but along with nish reply, if we have another always on top window (let's say Task Manager), then the latter becomes the always on top :(...

Can I keep invoking Qt::WindowStaysOnTopHint in a similar way like SetWindowPos ?

The thing is, it can be easily done with windows api by using SetWindowPos with always on top flag. So if the Task Manager becomes always on top then by just calling SetWindowPos again, it puts the desired window on top. In my original code, i call this SetWindowPos every some milliseconds so the user doesn't really have anytime to do anything.

wysota
28th October 2011, 07:55
I also have no ideia, but what about if you try event filters to cath Alt-Tab and or losefocus event to try to prevent losing focus ?

This won't work as alt+tab is handled by the operating system and not forwarded to your application. Besides, alt+tab is not the only way to get the application window out of your view.