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. Please help with Qt::WindowStaysOnTopHint
Forum Updated to NodeBB v4.3 + New Features

Please help with Qt::WindowStaysOnTopHint

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 6 Posters 4.9k Views 2 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.
  • Q Offline
    Q Offline
    qAlexKo
    wrote on last edited by
    #1

    (Linux Debian) I've made a function to make the app window to be always on the top. But I can't make the function which cancel that mode back (to normal mode). Please help.

    static Qt::WindowFlags flags_mem;
    void Tblf::on_mi_over_all_windows_triggered()
    {
    flags_mem = windowFlags();
    setWindowFlag(Qt::WindowStaysOnTopHint, true);
    show();
    activateWindow();
    }
    //---------------------
    void Tblf::on_mi_notover_all_windows_triggered()
    {
    setWindowFlags(flags_mem);
    show();
    activateWindow();
    //raise();
    }

    jsulmJ JonBJ 2 Replies Last reply
    0
    • Q qAlexKo

      (Linux Debian) I've made a function to make the app window to be always on the top. But I can't make the function which cancel that mode back (to normal mode). Please help.

      static Qt::WindowFlags flags_mem;
      void Tblf::on_mi_over_all_windows_triggered()
      {
      flags_mem = windowFlags();
      setWindowFlag(Qt::WindowStaysOnTopHint, true);
      show();
      activateWindow();
      }
      //---------------------
      void Tblf::on_mi_notover_all_windows_triggered()
      {
      setWindowFlags(flags_mem);
      show();
      activateWindow();
      //raise();
      }

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @qAlexKo Hi!
      Did you make sure that on_mi_notover_all_windows_triggered() is actually called?
      Also, there is no need to store all the flags in a member variable, setWindowFlag(Qt::WindowStaysOnTopHint, false) should do.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qAlexKo
        wrote on last edited by qAlexKo
        #3

        @jsulm said in Please help with Qt::WindowStaysOnTopHint:

        Did you make sure that on_mi_notover_all_windows_triggered() is actually called?
        Also, there is no need to store all the flags in a member variable, setWindowFlag(Qt::WindowStaysOnTopHint, false) should do.

        I did as you said also. The funcion on_mi_notover_all_windows_triggered() is called I checked it in the debugger. Please note that the cancelling "always on top mode" is not working only after you click "always on top" mode" first (on_mi_over_all_windows_triggered() I mean). Please check it.

        void Tblf::on_mi_over_all_windows_triggered()
        {
        setWindowFlag(Qt::WindowStaysOnTopHint, true);
        show();
        activateWindow();
        }
        //---------------------
        void Tblf::on_mi_notover_all_windows_triggered()
        {
        setWindowFlag(Qt::WindowStaysOnTopHint, false);
        show();
        activateWindow();
        }

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          You should test the WindowFlags example and see how it behaves on your system.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          Q 1 Reply Last reply
          1
          • SGaistS SGaist

            Hi,

            You should test the WindowFlags example and see how it behaves on your system.

            Q Offline
            Q Offline
            qAlexKo
            wrote on last edited by qAlexKo
            #5

            @SGaist said in Please help with Qt::WindowStaysOnTopHint:

            You should test the WindowFlags example and see how it behaves on your system.

            I have tested it - you can check "Window stays on top" and make the window "always on top" - but you cannot cancel the mode. I mean after unchecking "Window stays on top" the the new created window will be on top anyway (even after you choose another option). It is a poor example (for people who want to turn on/off the option "stay on top"). The QTcreator developers who put this example should know about it.

            jsulmJ JonBJ 2 Replies Last reply
            0
            • Q qAlexKo

              @SGaist said in Please help with Qt::WindowStaysOnTopHint:

              You should test the WindowFlags example and see how it behaves on your system.

              I have tested it - you can check "Window stays on top" and make the window "always on top" - but you cannot cancel the mode. I mean after unchecking "Window stays on top" the the new created window will be on top anyway (even after you choose another option). It is a poor example (for people who want to turn on/off the option "stay on top"). The QTcreator developers who put this example should know about it.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @qAlexKo said in Please help with Qt::WindowStaysOnTopHint:

              The QTcreator developers who put this example should know about it.

              Well, then you should let them know - file a bug. They can't test on each and every platform with all existing desktop environments and window managers. File a bug on Qt bug tracker and describe your setup including used window manager/desktop environment.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2
              • Q qAlexKo

                @SGaist said in Please help with Qt::WindowStaysOnTopHint:

                You should test the WindowFlags example and see how it behaves on your system.

                I have tested it - you can check "Window stays on top" and make the window "always on top" - but you cannot cancel the mode. I mean after unchecking "Window stays on top" the the new created window will be on top anyway (even after you choose another option). It is a poor example (for people who want to turn on/off the option "stay on top"). The QTcreator developers who put this example should know about it.

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #7

                @qAlexKo
                This has been reported as a problem under X11 a couple of times that I can see in posts, e.g. https://forum.qt.io/topic/77475/remove-qt-windowstaysontophint-flag-in-linux and https://stackoverflow.com/questions/53141178/pyqt5-cant-delete-flag-windowstaysontophint-under-ubuntu-18-04.

                Unfortunately I do not see a solution or workaround, nor whether this has been raised as a Qt bug or not.

                There is also https://www.qtcentre.org/threads/5730-Changing-AlwaysOnTop-window-flag, but I'm not sure if it applies to X11. (Possibly similar: https://forum.qt.io/topic/31197/unset-qt-windowstaysontophint-flag-problem. Looks like this has been behaviour at least since 2013!) Someone there claimed to get it working perhaps with a hide()/show(), which you might try?

                Q 1 Reply Last reply
                2
                • Q qAlexKo

                  (Linux Debian) I've made a function to make the app window to be always on the top. But I can't make the function which cancel that mode back (to normal mode). Please help.

                  static Qt::WindowFlags flags_mem;
                  void Tblf::on_mi_over_all_windows_triggered()
                  {
                  flags_mem = windowFlags();
                  setWindowFlag(Qt::WindowStaysOnTopHint, true);
                  show();
                  activateWindow();
                  }
                  //---------------------
                  void Tblf::on_mi_notover_all_windows_triggered()
                  {
                  setWindowFlags(flags_mem);
                  show();
                  activateWindow();
                  //raise();
                  }

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #8

                  @qAlexKo
                  You may not like to hear this, but https://bugreports.qt.io/browse/QTBUG-69515 seems to address this, but shows:

                  Fix Version/s:
                  6.2.0 Beta3, 6.3.0 Alpha, 5.15.6

                  So you may have to wait for/get one of these....

                  JKSHJ 1 Reply Last reply
                  2
                  • JonBJ JonB

                    @qAlexKo
                    You may not like to hear this, but https://bugreports.qt.io/browse/QTBUG-69515 seems to address this, but shows:

                    Fix Version/s:
                    6.2.0 Beta3, 6.3.0 Alpha, 5.15.6

                    So you may have to wait for/get one of these....

                    JKSHJ Offline
                    JKSHJ Offline
                    JKSH
                    Moderators
                    wrote on last edited by
                    #9

                    @JonB said in Please help with Qt::WindowStaysOnTopHint:

                    You may not like to hear this, but https://bugreports.qt.io/browse/QTBUG-69515 seems to address this, but shows:

                    Fix Version/s:
                    6.2.0 Beta3, 6.3.0 Alpha, 5.15.6

                    So you may have to wait for/get one of these....

                    The Qt 6.2.0 Release Candidate is available to everyone for testing right now. Or, you can wait till Qt 6.2 is released (it is scheduled for 30 September 2021). Or, if you are a commercial customer, you can download Qt 5.15.6 right now.

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    1 Reply Last reply
                    3
                    • JonBJ JonB

                      @qAlexKo
                      This has been reported as a problem under X11 a couple of times that I can see in posts, e.g. https://forum.qt.io/topic/77475/remove-qt-windowstaysontophint-flag-in-linux and https://stackoverflow.com/questions/53141178/pyqt5-cant-delete-flag-windowstaysontophint-under-ubuntu-18-04.

                      Unfortunately I do not see a solution or workaround, nor whether this has been raised as a Qt bug or not.

                      There is also https://www.qtcentre.org/threads/5730-Changing-AlwaysOnTop-window-flag, but I'm not sure if it applies to X11. (Possibly similar: https://forum.qt.io/topic/31197/unset-qt-windowstaysontophint-flag-problem. Looks like this has been behaviour at least since 2013!) Someone there claimed to get it working perhaps with a hide()/show(), which you might try?

                      Q Offline
                      Q Offline
                      qAlexKo
                      wrote on last edited by qAlexKo
                      #10

                      @JonB said in Please help with Qt::WindowStaysOnTopHint:

                      This has been reported as a problem under X11 a couple of times that I can see in posts, e.g. https://forum.qt.io/topic/77475/remove-qt-perhaps with a
                      <skipped>

                      Yes, it is an issue for many people. BTW - if you go to form system menu (upper left corner) you go to Properties and you can remove that stubborn flag manually.

                      <skipped>
                      hide()/show(), which you might try?

                      I tried without success.
                      Anyway thanks.

                      1 Reply Last reply
                      0
                      • JoeCFDJ Offline
                        JoeCFDJ Offline
                        JoeCFD
                        wrote on last edited by
                        #11

                        One way to work around this is to disable all other widgets when your window or dialog is on the top and enable all of them after this window or dialog is closed.

                        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