3 Attachment(s)
QMainWindow and its QDockWidget
Hi everybody,
I have a simple QMainWindow with a QDockWidget (a tool box) and a central widget (see the joined file called MainWindow1.jpg I don't know how to insert them directly in the text).
When I click on one button of the tool box, I need to change the central widget of the main window :
Code:
delete centralWidget();
setCentralWidget(quit);
updateGeometry();
update();
But the problem is that the dock widget (the tool box) now takes a half of the main window horizontaly !!!! (see MainWindow2.jpg) :confused:
To avoid the resizing of the dock widget I wrote the following code:
Code:
setMinimumWidth(m_toolBox->width());
setMaximumWidth(m_toolBox->width());
The result was not what I expected : the dock widget is correctly resized but there is a kind of frame taking a half of the main window !!!! (see MainWindow3.jpg)
Somebody have an idea?
Re: QMainWindow and its QDockWidget
The docs say:
Quote:
void QMainWindow::setCentralWidget ( QWidget * widget )
Sets the given widget to be the main window's central widget.
Warning: This function should be called at most once for each main window instance
Maybe you should use QStackedWidget as a central widget?
Re: QMainWindow and its QDockWidget
Thanks for your advice. It's true that the behaviour was not very nice.
;)