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. Qt::WindowStaysOnTopHint related question
QtWS25 Last Chance

Qt::WindowStaysOnTopHint related question

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 5.6k Views
  • 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.
  • S Offline
    S Offline
    Sofia
    wrote on last edited by
    #1

    Hi All,
    I examined Qt::WindowStaysOnTopHint flag of widget via Examples\Qt-5.9.1\widgets\widgets\windowflags application.
    The window with such a flag stays always foreground even I click to the other, not mine, application.
    It looks very strange. I need the window to be always shown on the screen but only inside my application. Not on the top of web-browser, Skype, mail and all-all-all applications on my computer!
    Is there any way provided to achieve that?
    Thank you!

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      That is what WindowStaysOnTopHint does when the OS supports it.
      You can use QDialog to open a window that will stay on top of mainwindow.
      At least when its modal.

      But what effect are you after ?

      There are also http://doc.qt.io/qt-5/qdockwidget.html
      which allowed to be embedded into main app but also floated and become a windows on its on.
      Sort of like an old MDI app but with free windows.

      1 Reply Last reply
      3
      • S Offline
        S Offline
        Sofia
        wrote on last edited by Sofia
        #3

        Thanks for your answer.
        My application is an editor fundamentally (I mean UI) like Adobe Photoshop for example. It has working windows and auxiliary toolbars and panels.
        I want toolbars and panels be always foreground for working windows.

        It's so cool on Mac: Qt::Tool windows have foreground priority on Qt::Window windows.
        "On macOS, tool windows correspond to the Floating class of windows. This means that the window lives on a level above normal windows making it impossible to put a normal window on top of it. "
        I want to have the same on Windows!
        Qt::WindowStaysOnTopHint seems to do what I need, but my panels are ALWAYS stay on the screen for all applications. Who needs that?

        Now I try to set and clean WindowStaysOnTopHint on QEvent::ApplicationActivate and QEvent::ApplicationDeactivate but I have a lot of weird side effects.!0_1510642908415_panels.png

        JonBJ 1 Reply Last reply
        0
        • S Sofia

          Thanks for your answer.
          My application is an editor fundamentally (I mean UI) like Adobe Photoshop for example. It has working windows and auxiliary toolbars and panels.
          I want toolbars and panels be always foreground for working windows.

          It's so cool on Mac: Qt::Tool windows have foreground priority on Qt::Window windows.
          "On macOS, tool windows correspond to the Floating class of windows. This means that the window lives on a level above normal windows making it impossible to put a normal window on top of it. "
          I want to have the same on Windows!
          Qt::WindowStaysOnTopHint seems to do what I need, but my panels are ALWAYS stay on the screen for all applications. Who needs that?

          Now I try to set and clean WindowStaysOnTopHint on QEvent::ApplicationActivate and QEvent::ApplicationDeactivate but I have a lot of weird side effects.!0_1510642908415_panels.png

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by JonB
          #4

          @Sofia
          The behaviour should already be what you desire under Windows, i.e. on top only of application window not other desktop windows. Show some of your code/window flags?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sofia
            wrote on last edited by
            #5

            Actually official qt's example \Qt5.9.1\Examples\Qt-5.9.1\widgets\widgets\windowflags is enough.
            I'll try qt 5.9.2 now, but for 5.9.1 Qt::Window and Qt::WindowStaysOnTopHint chosen in "windowflags" example application make resulting window to stay on the screen in spite of current active program.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Sofia
              wrote on last edited by
              #6

              Qt support has helped me. Windows with WindowStaysOnTopHint really should always stay foreground on the screen. It's proper behaviour. So the following code made my goal:

              connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(doStaysOnTopFlagProcessing(Qt::ApplicationState)));

              void MyToolbar::doStaysOnTopFlagProcessing(Qt::ApplicationState s)
              {
              //if (parentWidget()) return;
              if (s == Qt::ApplicationActive) {
              setWindowFlag(Qt::WindowStaysOnTopHint);
              show();
              }
              else {
              setWindowFlag(Qt::WindowStaysOnTopHint, false);
              lower(); // or hide()
              }
              }

              1 Reply Last reply
              4

              • Login

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