How to get a QDockWidget to auto resize?
This QDockWidget contains a QGridLayout.
At run time a user can right click on some widgets in another area and add them to the grid of this dock widget. The widgets just overlap and look bad until the user manually resizes the dock widget. When they manually expand the dock widget to an acceptable grid look, that becomes the minimum size. I've also noticed that if you toggle the dock window visibility off and then on it will resize to an appropriate minimum size.
How can i get the dockwidget to auto resize? :confused:
Re: How to get a QDockWidget to auto resize?
Try QWidget::updateGeometry() or QGridLayout::update().
Re: How to get a QDockWidget to auto resize?
I've tried:
QGridLayout::update()
QDockWidget::update()
QDockWidget::updateGeometry()
QDockWidget::resize(sizeHint())
QDockWidget::resize(QGridLayout::sizeHint())
none of these help.
Re: How to get a QDockWidget to auto resize?
Ok, in my dock widget constructor i call setMinimumWidth(150). If i comment this line out then the dock widget auto resizes correctly.
This may be an acceptable solution. Now the only undesirable behavior is that when the dock widget contains nothing in the grid, the window width is small. This makes the window title scrunched up and looks funny.
Re: How to get a QDockWidget to auto resize?
As a place holder I added a QLabel to the gridlayout in the contructor with a welcome message. This solves the width issue and auto resize works correctly.