I use a subclass of QDockWidget with a little trick. The "topLevelChanged" signal is connected to this member slot :
void MyDockWidget::updateWindowFlags(bool topLevel)
{
if (topLevel == true)
{
setWindowFlags(Qt::Dialog|Qt::CustomizeWindowHint|Qt::WindowTitleHint|Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint);
// "setWindowFlags" hides the widget, show it again
show();
}
}
This works well (at least on Windows, which is my target) and display a "maximize" button in the title bar.
Now I want to make the dock widget behave like a "top level" widget : not always on top of the main window and appears in taskbar.
I've tried to :
- reparent the dock widget to NULL when it is detached from main window
- reparent the dock widget to previous parent when it is re-attached from main window
But there is still some problems : the user can't use drag'n'drop anymore to re-attach the dock to the main window.
I think this is because the parent is NULL, so the dock widget doesn't know where it should re-attach on drag'n'drop.
Is there any way to have the desired behaviour (dock widget not always on top and appears in task bar) without re-parenting it to NULL ? Playing with some flags ?
Or is there anyway to have the dock widget to behave properly when its parent is set to NULL ?
Thanks
You can set the windows EX style WS_EX_APPWINDOW: