QSplitter LayoutStretch equivalent?



  • When using a QHBoxLayout, I can change the relative sizes of each section by setting the LayoutStretch property. E.g. if there are 3 sections, setting it to (2,1,1) makes the first section twice as big as the second two. However, if I switch to a QSplitter, there is no longer this property, and I do not like how it is choosing to split the sections.

    Is it possible to specify these splits in QtDesigner?

    Thanks,

    David



  • Do you mean QSplitter::setStretchFactor(int index, int stretch) ?



  • Possibly - but that property doesn't seem to be accessibly through QtDesigner, is that correct?



  • Doesn't seem so, no. However, can't you just give each of the widgets inside the splitter a stretch factor?



  • Hm, using that technique the stretch seems to be applied in the preview, but not directly in the designer?

    I added three buttons to a widget. I clicked the three of them, and did "Layout in Horizontal Splitter". Then I gave the widget a vertical layout (I think this should behave identically if I had instead given it a horizontal layout?). I set the Horizontal Stretch of the first two buttons to 1, and the Horizontal Stretch of the last button to 2. In the designer, all 3 buttons are the same width. When I Form -> Preview, the last button is twice the width (as desired).

    Is this the behavior you would expect? I guess I am confused because in the past I've noticed the stretch of an HBoxLayout seems to be applied directly in the designer?



  • I've created a feature request to include the layoutStretch property for QSplitter into Qt Designer: https://bugreports.qt.io/browse/QTCREATORBUG-16955


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.