我正在使用 Qt4 Designer 创建一个简单的 GUI。 我在 Dialog 中添加了一个 QTableWidget 。我的表格中只需要一列,并且我希望该列将自身拉伸到最大宽度。但它似乎是固定宽度的。
我尝试从编辑器中将属性
horizontalHeaderStretchLastSection
设置为 true
,但没有帮助。
谁能告诉我应该编辑哪个属性?
下面是我正在使用的 QTableWidget 的其余属性。
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>180</x>
<y>460</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QTableWidget" name="tableWidget">
<property name="geometry">
<rect>
<x>40</x>
<y>70</y>
<width>256</width>
<height>192</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="midLineWidth">
<number>1</number>
</property>
<attribute name="horizontalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>107</number>
</attribute>
<attribute name="horizontalHeaderHighlightSections">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<row>
<property name="text">
<string>New Row</string>
</property>
</row>
<row>
<property name="text">
<string>rrr</string>
</property>
</row>
<row>
<property name="text">
<string>gggg</string>
</property>
</row>
</widget>