[Solved] QDockWidget - disable "always on top"
-
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?
-
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.
-
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?
-
@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...
-
@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. -
@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...
-
@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.
-
@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.
-
@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?