QScrollArea widget is not expanding with a Flowlayout
Asked Answered
T

2

7

I have a ui with a QScrollArea Widget. The QScrollArea uses a Flowlayout. My problem is when I add widgets to my layout the scroll area begins to scroll and does not expand when it has room to expand. I want the scroll area to expand to its limit before the scroll bar appears first.

How can I get the scroll area to expand before the scroll bar appears?

Tupper answered 31/1, 2013 at 20:56 Comment(2)
What does the layout look like for the widget that the QScrollArea is sitting in? Is there a layout?Aquarelle
@suslik The QScrollArea sits in a QFrame Widget.Tupper
A
7

can you try doing setWidgetResizable(true) for your QScrollArea

ScrollArea->setWidgetResizable(true);
Apotheosize answered 1/2, 2013 at 6:29 Comment(0)
L
0

A couple of suggestions:

  1. Ensure that the size policy of the scroll area itself is Expanding.
  2. Set the "stretch" values of the size policy of the scroll area to a value greater than that of the other widgets in the same layout. Ie:

    QSizePolicy policy = pScrollArea->sizePolicy()
    
    policy.setVerticalStretch(1);
    policy.setHorizontalStretch(1);
    

    This assumes that the siblings of the scroll area (if any) have a stretch value of 0 (the default).

  3. Subclass the scroll area and override the sizeHint() method.

Laaland answered 8/2, 2013 at 17:31 Comment(1)
Thanks for the suggestions. I've tried 1 and 2 and will work on 3 shortly.Tupper

© 2022 - 2024 — McMap. All rights reserved.