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.

有帮助吗?

解决方案

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().

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top