【发布时间】:2019-12-03 16:20:55
【问题描述】:
我正在使用带有“设计”工具的 Qt Creator,并且我有按钮网格,无论我如何调整它们的大小,它们都应该始终是正方形。
有什么想法吗?
这是我的网格在调整大小时的样子:
这里是完美的正方形,但是如果我把我的窗口变小...
...看起来像这样:
这是.ui:
<layout class="QGridLayout" name="gridLayout_5" rowstretch="0,0,0" columnstretch="0,0,0">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item row="2" column="1">
<widget class="QPushButton" name="downButton_3">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="grafics.qrc">
<normaloff>:/grafics/grafics/pfeile/pfeil_unten.tga</normaloff>:/grafics/grafics/pfeile/pfeil_unten.tga</iconset>
</property>
<property name="iconSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="upButton_3">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="grafics.qrc">
<normaloff>:/grafics/grafics/pfeile/pfeil_oben.tga</normaloff>:/grafics/grafics/pfeile/pfeil_oben.tga</iconset>
</property>
<property name="iconSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="waitButton_3">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<family>MS Shell Dlg 2</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="contextMenuPolicy">
<enum>Qt::DefaultContextMenu</enum>
</property>
<property name="text">
<string>W</string>
</property>
<property name="icon">
<iconset theme="&#9664"/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="leftButton_3">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="grafics.qrc">
<normaloff>:/grafics/grafics/pfeile/pfeil_links.tga</normaloff>:/grafics/grafics/pfeile/pfeil_links.tga</iconset>
</property>
<property name="iconSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="deleteButton_3">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string><</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="rightButton_3">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="grafics.qrc">
<normaloff>:/grafics/grafics/pfeile/pfeil_rechts.tga</normaloff>:/grafics/grafics/pfeile/pfeil_rechts.tga</iconset>
</property>
<property name="iconSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
</widget>
</item>
</layout>
【问题讨论】:
-
分享.ui ...
-
@eyllanesc 它的 html 真的想要吗?
-
如果您使用的是Qt Designer,那么您应该生成一个.ui 文件,它是一个XML 格式的文件,这是您必须共享的内容。
-
好的,请稍等
-
@eyllanesc 你编辑了什么吗?如果有,你改变了什么?
标签: qt qt-designer