[Qt-interest] How to alter QVBoxLayout widget spacing ?

John Posner jjposner at optimum.net
Wed Feb 17 15:28:08 CET 2010


On 2/17/2010 8:55 AM, Stephen Collyer wrote:
> I have some code which creates a set of widgets with a structure like so:
>
> A QScrollArea contains a ParagraphList as its widget
> A ParagraphList has a QVBoxLayout containing ParagraphRow widgets.
> A ParagraphRow has a QHBoxLayout containing QTextEdit widgets.
>
> My problem is that the spacing between each ParagraphRow widget is too 
> great,
> and I can't find any way to reduce it. I've tried adding stretches to 
> the QVBoxLayout,
> and altering the layout's spacing and marging, yet none of this 
> reduces it.
>
> This is a picture of the layout which shows the problem:
>
> http://dl.dropbox.com/u/4271762/snapshot1.png
>
> Can anyone suggest anything else that I can try ?
>

For both the QVBoxLayouts and the QHBoxLayouts, fiddle with:

   layout.setSpacing()
   layout.setContentsMargins()

HTH,
John





More information about the Qt-interest-old mailing list