[Solved] QDockWidget - disable "always on top"
Is there a way how to disable "always on top" behavior of floating dock widget?
Hi and welcome to devnet,
You can try to unset the Qt::WindowStaysOnTopHint flag on your QDockWidget
Hope it helps
I have tried it this way:
@setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);@
But doesn't work. Floating dock widget is still always on top of MainWindow.
The QDocWidget, I believe, is parented by the MainWindow. As such -- if I recall -- it will always remain on top of that window, regardless of the status of the WindowFlags.
If I'm wrong, someone please feel free to correct me.
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.
There is no use case. I was just curious about possibilities of using QDockWidget.
The option described by Chris looks acceptable.
Thanks to all.
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?