سؤال

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