Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Asymmetrical layout?



  • Is there any way to do an asymmetrical layout? Like if I wanted a single horizontal layout with just two controls in it to be split 70/30 instead of 50/50 is there a way to do that? Or is the only way to set a fixed size on one of the two controls and let the other fill the difference?

    And to be clear I'm talking about using the automatic layout properties not manually overriding sizeEvent and doing it programmatically. I'll do that if I have to, but I want to make sure I'm not overlooking some automatic option that does this.


  • Lifetime Qt Champion

    Hi,

    Use the stretch parameter when adding your widget to match the ratio you want.



  • Thanks, that does work. But I'm curious what that number means? Is it a percentage? I looked at the docs and it's just called a "stretch factor" but it doesn't explain exactly what the value means.



  • Answering my own question.... It's not a percentage. It seems to be some sort of relative scale where higher numbers get more scaling than lower numbers, but the numbers do not directly correlated to the percentage the widget scales. Kind of a weird system but with some trial and error I was able to get the results I wanted.


Log in to reply