Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QDockWidget initial width

How do I set the initial width of a QDockWidget?

I have implemented the sizeHint function but what next?

like image 764
Phil Hannent Avatar asked Oct 10 '08 12:10

Phil Hannent


1 Answers

The documentation for QDockWidget says:

A QDockWidget acts as a wrapper for its child widget, set with setWidget(). Custom size hints, minimum and maximum sizes and size policies should be implemented in the child widget. QDockWidget will respect them, adjusting its own constraints to include the frame and title. Size constraints should not be set on the QDockWidget itself, because they change depending on wether it is docked; a docked QDockWidget has no frame and a smaller title bar.

So the size hint is taken from whatever you put in the dock widget. Have you tried setting the size of the QDockWidget's child?

But, I agree with Marius, the best thing to do is probably to use QSettings to save and restore the widths of all the dock windows when the application starts. Have a look at QMainWindow::saveState Apart from getting the data from saveState rather than from individual functions my save function looks very similar to the one given by Marius.

like image 76
David Dibben Avatar answered Oct 05 '22 01:10

David Dibben