addDockWidget && removeDockWidget trouble
Hello all!
This code is a part of my MainWindow class constructor
Code:
MainWindow::MainWindow()
{
....
dock->setWidget(l);
dock->setFloating(false);
addDockWidget(Qt::BottomDockWidgetArea, dock);
....
}
It works fine!
Why this code is incorrect (dock widget is invisible):
Code:
MainWindow::MainWindow()
{
....
dock->setWidget(l);
dock->setFloating(false);
addDockWidget(Qt::BottomDockWidgetArea, dock);
removeDockWidget(dock); /// Remove
addDockWidget(Qt::BottomDockWidgetArea, dock); /// And add again
....
}
Re: addDockWidget && removeDockWidget trouble
Removing the dock widget causes it to be hidden.
Docs say:
void QMainWindow::removeDockWidget ( QDockWidget * dockwidget )
Removes the dockwidget from the main window layout and hides it. Note that the dockwidget is not deleted.
So if you want to remove and add the same dock widget back and forth, you will have to explicitly call show() to get it visible again.