Important: Please read the Qt Code of Conduct -

ScrollArea assuming shorter width

  • Hello,

    I have a ScrollArea with a layout widget inside. I'm trying to set the ScrollArea to expand with the window size and, in case the window is narrower than the ScrollArea's contents, show the horizontal scroll bar.
    I have set the minimimWidth of the layout widget inside to determine the default width the ScrollArea outside should assume, the trouble is, the ScrollArea assumes a size lower than that, clipping its contents.
    If I set an equivalent minimumWidth to the ScrollArea, therefore showing it fully by default, then it doesn't show the scrollbar when the window is resized below its width.
    Any help?

  • Lifetime Qt Champion

    If understand you correctly, i think you should set a minimum size on the widgets you put in the layout
    else it will compress them and not show scrollbar. The Scroll area should just follow the layout on the window itself where its lives.
    See this with buttons that as a default fixed width.
    alt text

  • @mrjj The layout widgets' minimum sizes are set (thanks for the explanation). The ScrollArea's calculated width differs from the sum of these.

    I could fix this issue by noticing that the ScrollArea in question was atop another widget but not inside a vertical box. By layout both in a vertical box the ScrollArea's width was calculated correctly and functions properly.

Log in to reply