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. How to make window stay behind other windows ?
Forum Updated to NodeBB v4.3 + New Features

How to make window stay behind other windows ?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 5.1k 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.
  • K Offline
    K Offline
    kotl_give_me_mana
    wrote on last edited by
    #1

    I'm new in Qt. I have a fairly easy question that i cannot solve myself .

    I'm creating 5 windows (desktop, Leftbar, Rightbar, Leftbar, Bottombar, Topbar), i want to desktop window always stay bottom of other 4 window. When i click anywhere on desktop window other windows should continue to stay on top. How can i do this ?

    @int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

        Desktop desktop;
        desktop.show();
    
        Leftbar leftbar;
        leftbar.show();
    
        Rightbar rightbar;
        rightbar.show();
    
        Topbar topbar;
        topbar.show();
    
        Bottombar bottombar;
        bottombar.show(); 
    
        return a.exec();
    

    }@

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maximus
      wrote on last edited by
      #2

      Hey there, welcome to Qt!

      Check out theses posts :
      Have fun!

      http://www.qtcentre.org/threads/7384-Force-a-QDialog-to-be-the-top-level-Window-and-to-stay-at-this-level
      http://qt-project.org/forums/viewthread/1389
      http://www.qtforum.org/article/33148/a-modeless-dialog-that-is-always-on-top.html

      setWindowFlags(Qt::WindowStaysOnTopHint);


      Free Indoor Cycling Software - https://maximumtrainer.com

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kotl_give_me_mana
        wrote on last edited by
        #3

        Thank you for your answer, but when i use

        setWindowFlags(Qt::WindowStaysOnTopHint);

        on leftbar, rightbar, topbar and bottombar they stay on top of all windows (like when i open documents folder these windows continue to stay on top).

        I want these windows stay top of my "desktop" window, not all windows.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maximus
          wrote on last edited by
          #4

          I would put
          Qt::WindowStaysOnBottomHint
          on the Desktop window and not worry about the others.

          http://qt-project.org/doc/qt-4.8/qt.html#WindowType-enum

          Good luck


          Free Indoor Cycling Software - https://maximumtrainer.com

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kotl_give_me_mana
            wrote on last edited by
            #5

            I already put

            Qt::WindowStaysOnBottomHint on the desktop window,

            but it's not working. When i click on desktop window, other windows(Leftbar, Rightbar, Leftbar, Bottombar, Topbar) go bottom of desktop window.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              maximus
              wrote on last edited by
              #6

              For more complex behavior,
              You can subclass QWidget and reimplement focusInEvent and/or focusOutEvent to emit your custom signal, then process another Slot in another QWidget.

              for example, when focus is received on desktop, put another QWidget above (with raise()) or under it(lower()).


              Free Indoor Cycling Software - https://maximumtrainer.com

              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