Make QScrollArea fill available space
-
Here is a brief description of what I have:
- A vertical layout inside other layout in a complex form, not my code but I hope it does not matter.
- Three widgets inside vertical layout mentioned in 1, two of them have Preferred vertical size policy, no problems with them.
- One widget has a QScrollArea inside, everything else is inserted in runtime into the layout of the scroll area's contents widget.
I would like the widget with the QScrollArea to fill all available vertical space. Generally, window height is not large enough to accommodate everything within this widget (hence the scroll area), but with it it is always smaller than available vertical space. So I have a window with all other widgets nicely resizing, two widgets in the vertical layout (mentioned in 1) having fixed size, and the widget with the QScrollArea also always has the same vertical size. I think I have tried everything, spending hours and hours to test various combinations. Tried setting vertical size policy of the widget itself, of the QScrollArea inside it, and of its contents widget to Expanding. Tried setting stretch of the vertical layout (mentioned in 1). Tried calling resize() of the widget and of the QScrollArea manually. Nothing helps. The widget never resizes vertically and never fills available space.
-
Hi,
You should provide a minimal compilable example that shows this behavior. It will make it easier to help you find what's going on.
-
I've made a minimal example and found it working as expected. After carefully inspecting and comparing the sources and commenting some sections of the original to localize the problem I've found than some code was overwriting the size policy and messing with the layout. Problem solved.