I followed the advice of using setWindowFlags() and it worked for me. I did not notice any incorrect behavior from the dockWidget. Looks like the trolltech people have fixed it. Thanks!
// connect dockWidget's topLevelChanged signal, which is emitted when its floating property changes, to a user-defined slot
connect(ui.dockWidget, SIGNAL(topLevelChanged(bool)), this, SLOT(dockWidget_topLevelChanged(bool)));
// when the floating property of dockWidget is changed from docked to floating
// we make it a top level window (with minmize, maximize, and close button in the title bar)
// by calling setWindowFlags(Qt::Window)
// The dockWidget will automatically regain it's Qt::widget flag when it becomes docked again (by dragging it to the right place or double clicking the title bar)
void CMainWindow::dockWidget_topLevelChanged(bool isFloating)
{
if(isFloating)
{ ui.dockWidget->setWindowFlags(Qt::Window);
// setWindowFlags calls setParent() when changing the flags for a window, causing the widget to be hidden.
// You must call show() to make the widget visible again
ui.dockWidget->show();
}
}
// connect dockWidget's topLevelChanged signal, which is emitted when its floating property changes, to a user-defined slot
connect(ui.dockWidget, SIGNAL(topLevelChanged(bool)), this, SLOT(dockWidget_topLevelChanged(bool)));
// when the floating property of dockWidget is changed from docked to floating
// we make it a top level window (with minmize, maximize, and close button in the title bar)
// by calling setWindowFlags(Qt::Window)
// The dockWidget will automatically regain it's Qt::widget flag when it becomes docked again (by dragging it to the right place or double clicking the title bar)
void CMainWindow::dockWidget_topLevelChanged(bool isFloating)
{
if(isFloating)
{ ui.dockWidget->setWindowFlags(Qt::Window);
// setWindowFlags calls setParent() when changing the flags for a window, causing the widget to be hidden.
// You must call show() to make the widget visible again
ui.dockWidget->show();
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks