How to get QHBoxLayout or QVBoxLayout to auto expanding with its parent QWidget in .ui file
-
I didn't found any way to do that.
-
Comes with a result, the QVBoxLayout 's parent should be the TopWidget,
then when we resize the widget, the QVBoxLayout will auto-resize with it's parent widget, that's nice.@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GroundMain</class>
<widget class="QWidget" name="GroundMain">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>960</width>
<height>540</height>
</rect>
</property>
<property name="windowTitle">
<string>控制台%1</string>
</property>
<property name="styleSheet">
<string notr="true">
QWidget#widgetA{
background:green;
padding: 0px;
border:0px;
margin:0px 0px 0px 0px;
}QWidget#widgetB{
background:blue;
padding: 0px;
border:0px;
margin:0px 0px 0px 0px;
}QWidget#GroundMain{
border:0px
padding: 0px;
margin:0px 0px 0px 0px;
background:red;
}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="widgetA" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widgetB" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>@