Qt 5.7 QDockWidget default size

限于喜欢 提交于 2020-01-17 12:37:28

问题


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:


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.



来源:https://stackoverflow.com/questions/41231582/qt-5-7-qdockwidget-default-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!