Results 1 to 9 of 9

Thread: Keep making a widget as always on top

  1. #1
    Join Date
    Jul 2011
    Posts
    16
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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

    Louis

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Keep making a widget as always on top

    What platform are we talking about?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2011
    Posts
    16
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keep making a widget as always on top

    I am working on Windows XP. Qt 4.7.4.

    Many thanks,

    Louis

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Keep making a widget as always on top

    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
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Thanks
    23
    Thanked 32 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Keep making a widget as always on top

    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 ?
    __________________________________________________
    My projects: calculator MathGraphica ; SuperEpicMegaHero game ; GooglePlay ; bitbucket ; github
    Like my projects ? Buy me a kofi

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Keep making a widget as always on top

    Is Qt::WindowStaysOnTopHint ignored by Windows?

  7. #7
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Keep making a widget as always on top

    Quote Originally Posted by ChrisW67 View Post
    Is Qt::WindowStaysOnTopHint ignored by Windows?
    no. but they can be minimized/moved/hide behind other stay on top windows.

  8. #8
    Join Date
    Jul 2011
    Posts
    16
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keep making a widget as always on top

    Quote Originally Posted by ChrisW67 View Post
    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.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Keep making a widget as always on top

    Quote Originally Posted by john_god View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Making a chld widget semi transparent:works ony for full transparency.
    By savaliya_ambani in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 7th October 2010, 13:03
  2. making widget back from fullscreen
    By anoar in forum Qt Programming
    Replies: 2
    Last Post: 22nd September 2009, 17:13
  3. Drag widget example not making right
    By di_zou in forum Newbie
    Replies: 2
    Last Post: 16th September 2009, 11:14
  4. making .dll file
    By omprakash in forum Qt Programming
    Replies: 3
    Last Post: 29th July 2008, 19:49
  5. Making QT believe a widget is bigger
    By drhex in forum Qt Programming
    Replies: 2
    Last Post: 23rd September 2006, 13:17

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.