拉伸因子,会已有的部件紧凑挨近,只占据部件需要的大小位置,之后使用空白占据剩余的位置。
效果图如下:
第一个截图是使用了addStretch()方法的样子,第二个截图是没使用addStretch()方法的样子。可以看出,第一个截图中,
两个QHBoxLayout挨得比较紧凑,剩余位置都是空白区域;而第二个截图中,两个QHBoxLayout均分了区域
如果拉伸因子用在两个QHBoxLayout中间,则两个QHBoxLayout一个挨到顶部,一个挨到底部,中间全是空白区域,如图所示。