Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Keep making a widget as always on top
Forum Updated to NodeBB v4.3 + New Features

Keep making a widget as always on top

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 10.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nackasha
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • R Offline
      R Offline
      RazrFalcon
      wrote on last edited by
      #2

      "Qt::WindowStaysOnTopHint":http://doc.qt.nokia.com/latest/qt.html#WindowType-enum

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nackasha
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dmcr
          wrote on last edited by
          #4

          You can use QWidget->activateWindow()

          dmcr

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nackasha
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • N Offline
              N Offline
              nackasha
              wrote on last edited by
              #6

              Got it. Thank you. I used isminimized, and if yes then shownormal() ;

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved