[Qt-interest] QScrollArea expand question.

Tony Rietwyk tony.rietwyk at rightsoft.com.au
Mon Mar 30 09:23:29 CEST 2009


Hi Wim, 

> I have a widget inside a QScrollArea. The scroll area is 
> added to a vertical 
> layout (with some buttons underneath) all contained by a frame.
> 
> I want the scroll area to expand for as long as the added 
> space can be used by 
> the containing widget.  I.e when the extra space is not 
> longer usefull to the
> contained widget, the scrollbar should no longer expand.
> 
> Adding the scrollarea 'expanded' causes it to eat size even 
> if the contained 
> widget cannot use that space.
> 
> How can I acchieve this effect ?

Hi Wim, 

I think you want the maximum size of the scroll area to be the current size
of the scrolled widget.  In that case, override the resizeEvent of the
scrolled widget and call scroll_area.setMaximumSize().  You might need to
adjust each direction individually depending on whether that direction's
scroll bar is visible.  You'll also need to adjust for the scroll area
margins if set. 

Hope that helps,

Tony.




More information about the Qt-interest-old mailing list