Hi,

I am trying to write a code for a dockwidget that can be minimized instead of deleted. That is, if you press the X button, it should become as small as possible, showing only this X button. If you press the button again, it should resize to its original size.

I already managed to reimplement the closeEvent function such that the content of the dockwidget gets replaced by an empty widget on click on the X button. However, I could not figure out how to let the dockwidget adjust to the size of the empty widget (that is, as small as possible).

The central widget in the main window as expanding size policy, the dockwidget is set to preferred. I tried to call

Qt Code:
  1. adjustSize()
  2. resize(...)
  3. update()
  4. updateGeometry()
To copy to clipboard, switch view to plain text mode 

on both the dockwidget and it's widget, but there is simply no effect. I checked via qDebug that the widget size changes (wigdet->size()), but the size of the dockwidget remains unchanged.

So what is the correct way of resizing the dockwidget programatically during runtime?