I am trying to make an application consisting of QMainWindow , the central widget of which is QToolBar (this may not be normal for me, but toolbars work well for my purpose). Docks are only allowed below. I added a QDockWidget to it, and QAction in the QToolBar turned QDockWidget on and off using removeDockWidget() and restoreDockWidget() .
The default size of QMainWindow is 800 to 24, QToolBar s maximumHeight also set to 24. Immediately after calling removeDockWidget() QMainWindow s geometry returns to (0,0,800,24) using setGeometry() .
I want to achieve resizing QMainWindow s to 24 when uninstalling DockWidget . It seems that setGeometry() works, since the width and position change are correspondingly, but funny enough, the height does not shift. And this is my problem :)
What do you think?
Here is a screenshot illustrating the problem.
NB: if I create the same script using QWidget, not QMainWindow, and using the show() or hide() child widget, I can resize the parent without adjustments with adjustSize() : this is the problem here above the QMainWindow specification.
source share