Qt 5.7 QDockWidget default size

1.6k views Asked by At

I am trying to have following setup:

at start (when main window is opened) I want to have 2 QDockWidgets at left with width 400px and height 1/2 (each) of QMainWindows height. At the left, 3 QDockWidgets with width 400px and height 1/3 (each) of QMainWindows height. All of 5 widgets have to be resizable. That means using setFixSize() won't work in this case.

So far I've tried changing Geometry>Width and Gemetry>Height in designed -> didn't work.

Then I tried using resize() in main window constructor but it didn't work either.

Why doesn't Gemetry>Height/Width and resize() have any influence on widgets size and how to achieve main window layout as described above?

1

There are 1 answers

4
ekhumoro On

The dock-widgets will be added to the layout of the main-window, so resizing them will have no effect. One work-around for this is to reimplement the sizeHint of the content widget that is added to each dock-widget.

I suppose another way of looking at this is to let the user arrange the dock-widgets in whatever way they prefer, and then use saveState and restoreState to manage the initial state.