Question

I have a QtGui.QVBoxLayout widget which exists inside a main QtGui.QGridLayout layout, which extends and centers the items all over the place (The left side)

I want the items to get stacked up at the top of the widget (The right side)

enter image description here

How can I achieve this? I know it has something to do with SizeHint, but I'm not sure how to use it.

Was it helpful?

Solution

A QBoxLayout will distribute the widgets evenly over the available space. The easiest way to keep all the widgets packed together at the top of a QVBoxLayout, is to add a stretchable spacing at the bottom that will push all the widgets up.

You can add a stretch that will take up as much space as it can with QBoxLayout::addStretch().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top