0

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?

carobnodrvo
  • 1,021
  • 1
  • 9
  • 32

1 Answers1

2

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.

ekhumoro
  • 115,249
  • 20
  • 229
  • 336
  • And if content of a docking widget is, e.g., `QWebEngineView`? I don't think inheriting from it only to reimplement `sizeHint` is a good idea, or is it not? – carobnodrvo Dec 20 '16 at 00:00
  • @carobnodrvo. Just use a simple `QWidget` subclass as a container for your real content. – ekhumoro Dec 20 '16 at 00:07
  • But my real content is `QWebEngineView`. – carobnodrvo Dec 20 '16 at 11:21
  • 1
    @carobnodrvo. So what? Just add a layout to the container widget and then add whatever widget(s) you like to that layout. You might also want to set the layout margins to zero, – ekhumoro Dec 20 '16 at 17:01