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. [Solved] QDockWidget - disable "always on top"
QtWS25 Last Chance

[Solved] QDockWidget - disable "always on top"

Scheduled Pinned Locked Moved General and Desktop
14 Posts 7 Posters 9.3k 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.
  • Chris KawaC Offline
    Chris KawaC Offline
    Chris Kawa
    Lifetime Qt Champion
    wrote on last edited by
    #5

    mlong is right - you can't put a child under a parent. What you can do is detect when window is undocked via its topLevelChanged signal. Inside that signal handler you can remove widget with contents from the dock, hide the dock and display contents as a separate parent-less window. You won't be able to automatically dock it back again though.

    Anyway - all this seems like something a user almost never wants(thus it's hard to do in Qt or without even). What's your use case for this?

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

      I misunderstood your problem.

      mlong and Chris Kawa are right. And Chris has a very good point when he says you are about to break UI guidelines.

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

      1 Reply Last reply
      0
      • _rth__ Offline
        _rth__ Offline
        _rth_
        wrote on last edited by
        #7

        Hi.

        There is no use case. I was just curious about possibilities of using QDockWidget.

        The option described by Chris looks acceptable.

        Thanks to all.

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qtcad
          wrote on last edited by
          #8

          I do have a use case for this, actually:

          I have a console widget docked into a main window that, by default, is part of the main window. The design intent, however, is for the console to be removable ("undockable") by the user to become its own floating window, and dockable again if they want to put it back into the main window. Chris's option, unfortunately, loses the "put it back" capability.

          Would it be possible to have the new toplevel window implement a function that would check its positioning relative to the dock and rebuild the docked verison of the widget in an imitation of the normal floating dock window? Even better, has anyone already done this before?

          1 Reply Last reply
          0
          • Chris KawaC Chris Kawa

            mlong is right - you can't put a child under a parent. What you can do is detect when window is undocked via its topLevelChanged signal. Inside that signal handler you can remove widget with contents from the dock, hide the dock and display contents as a separate parent-less window. You won't be able to automatically dock it back again though.

            Anyway - all this seems like something a user almost never wants(thus it's hard to do in Qt or without even). What's your use case for this?

            DiracsbracketD Offline
            DiracsbracketD Offline
            Diracsbracket
            wrote on last edited by Diracsbracket
            #9

            @Chris-Kawa said in [Solved] QDockWidget - disable "always on top":

            Anyway - all this seems like something a user almost never wants(thus it's hard to do in Qt or without even). What's your use case for this?

            Of course there is a use case for this: sometimes, I want to undock the dockwidget to see its content on a larger scale than when docked, for example a graph, or even a list with data.
            However, when doing this, the dock will hide the parent window (main app) which can also contain other data. I would like to be able to set either the Main App window or the DockWidget to the foreground when changing focus to it. However due to this "always on top" behavior of the DockWidget, this is not possible, and I have no other option than to either move the Dock widget to see the data in the Main App window, or dock the widget back in...

            I am surprised that not more people seem to need such functionality...

            Chris KawaC 1 Reply Last reply
            0
            • DiracsbracketD Diracsbracket

              @Chris-Kawa said in [Solved] QDockWidget - disable "always on top":

              Anyway - all this seems like something a user almost never wants(thus it's hard to do in Qt or without even). What's your use case for this?

              Of course there is a use case for this: sometimes, I want to undock the dockwidget to see its content on a larger scale than when docked, for example a graph, or even a list with data.
              However, when doing this, the dock will hide the parent window (main app) which can also contain other data. I would like to be able to set either the Main App window or the DockWidget to the foreground when changing focus to it. However due to this "always on top" behavior of the DockWidget, this is not possible, and I have no other option than to either move the Dock widget to see the data in the Main App window, or dock the widget back in...

              I am surprised that not more people seem to need such functionality...

              Chris KawaC Offline
              Chris KawaC Offline
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by
              #10

              @Diracsbracket Dock widgets are tool windows, not top level windows (in the sense of parent-child hierarchy). As such they don't show up in the taskbar as separate windows. If such window would become hidden under its parent there would be no way for user to know it's there or switch to it.
              If you want this behavior the window needs to show up in the taskbar and for this it needs to be a top level window (i.e. have no parent). That's not what docks do or are for. If your app has 20 docks (one of mine can have up to about 50 for example) you don't want that many icons on the taskbar.

              B 1 Reply Last reply
              1
              • DiracsbracketD Offline
                DiracsbracketD Offline
                Diracsbracket
                wrote on last edited by
                #11

                @Chris-Kawa said in [Solved] QDockWidget - disable "always on top":

                If such window would become hidden under its parent there would be no way for user to know it's there or switch to it.

                Since there is a parent-child relationship and the parent in this case is a MainWindow app, I could imagine the MainWindow managing its own "taskbar" showing all its undocked (floating) docks at a particular time, and in this case, the problem you mention would be solved. This "taskbar" would for instance be part of the status bar of the MainApp window...

                Chris KawaC 1 Reply Last reply
                0
                • DiracsbracketD Diracsbracket

                  @Chris-Kawa said in [Solved] QDockWidget - disable "always on top":

                  If such window would become hidden under its parent there would be no way for user to know it's there or switch to it.

                  Since there is a parent-child relationship and the parent in this case is a MainWindow app, I could imagine the MainWindow managing its own "taskbar" showing all its undocked (floating) docks at a particular time, and in this case, the problem you mention would be solved. This "taskbar" would for instance be part of the status bar of the MainApp window...

                  Chris KawaC Offline
                  Chris KawaC Offline
                  Chris Kawa
                  Lifetime Qt Champion
                  wrote on last edited by
                  #12

                  @Diracsbracket That's something you in particular might want but it's not something standard on any platform. If you want that you can implement it.

                  DiracsbracketD 1 Reply Last reply
                  1
                  • Chris KawaC Chris Kawa

                    @Diracsbracket That's something you in particular might want but it's not something standard on any platform. If you want that you can implement it.

                    DiracsbracketD Offline
                    DiracsbracketD Offline
                    Diracsbracket
                    wrote on last edited by Diracsbracket
                    #13

                    @Chris-Kawa said in [Solved] QDockWidget - disable "always on top":
                    Actually, thinking about it, the visibility problem you mentioned is nothing different than the same case where the Dock widget is closed/minimized, i.e. when it is made invisible. If you don't have some button/menu implemented to make it visible again, you must restart your program to get it back. I have a list of all the dock widgets in a menu called Windows. When one of the docks is closed, the checkbox in the menu gets unchecked. The associated action when checked again is to make it visible again. So really, no problem at all to have the parent on top of the Dock...

                    If you want that you can implement it.

                    Unfortunately, I'm not a good enough programmer to start and do this :-( Since the Dock was implemented the way it is, I guess there may be some deeper reasons why it is not allowed to be below its parent.

                    1 Reply Last reply
                    0
                    • Chris KawaC Chris Kawa

                      @Diracsbracket Dock widgets are tool windows, not top level windows (in the sense of parent-child hierarchy). As such they don't show up in the taskbar as separate windows. If such window would become hidden under its parent there would be no way for user to know it's there or switch to it.
                      If you want this behavior the window needs to show up in the taskbar and for this it needs to be a top level window (i.e. have no parent). That's not what docks do or are for. If your app has 20 docks (one of mine can have up to about 50 for example) you don't want that many icons on the taskbar.

                      B Offline
                      B Offline
                      Bamboleo
                      wrote on last edited by
                      #14

                      @Chris-Kawa said in [Solved] QDockWidget - disable "always on top":

                      As such they don't show up in the taskbar as separate windows. If such window would become hidden under its parent there would be no way for user to know it's there or switch to it.

                      Is this possible to do in PySie2 or 6.0.1? I mind undock QDockWidget and manage this from windows taskbar like sepaarate aps/windows?

                      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