undocking/detaching toolviews to regular windows instead of tool windows

René J.V. Bertin rjvbertin at gmail.com
Thu Oct 12 15:19:33 BST 2017

On Thursday October 12 2017 15:43:16 Kevin Funk wrote:

>Makes sense. Patches welcome.
>Should be easy enough, you need to reparent the widget contained in the 
>QDockWidget, set the Qt::Window flag and show it again. Work from there.

Hmm, I can try this too. For now I've tinkered with changing the window flags back to Qt::Window when the floating state changes. That also works but it's tricky (because apparently platform-dependent). But reparenting could have more side-effects, have you tried re-docking the window for instance?

This is something that can probably much better be done upstream: a QDockWidget::setFloatAsRegularWindow(bool) could modify how QDockWidget::setFloating(true) "tears off" windows.

Normally I'm all for giving the user choice, but wouldn't it be sufficient (better) in this case to let the toolview decide rather than adding a menu to obtain a different kind of floating window? That would give 2 menu actions to detach the window, which comes with having to handle transitions between those modes and will probably also lead to surprises when the floating windows are restored as Qt::Tool instead of Qt::Window.

FWIW, automatic restore is tricky to get right with my approach too. There is no state change notification of course, and apparently QDockWidget::isFloating() cannot yet be queried reliably in the ctor. I've been trying to work around this by re-attaching the windows on exit using QCoreApplication::aboutToQuit, but that only works on Mac. On Linux I simply don't get the signal. Another thing that makes restore tricky is the fact that the (documentation) toolview is restored multiple times; when it's being restored in detached mode I can see the window open and close multiple time while the session loads (possibly once per project).

>FWIW, René also cross-posted basically the same question to:
>  http://lists.qt-project.org/pipermail/interest/2017-October/028275.html

That was a general how-to.

More information about the KDevelop mailing list