设计师重叠问题
Designer Overlapping Issue
我遇到了小部件和布局在我的滚动区域内开始重叠的问题。
我当前的布局应该是这样的:
我的布局:
但最终像这样,小部件开始重叠(这是固定大小的组框):
重叠示例:
或者这个(没有固定大小的分组框):
“Sqished”小部件并推出视图小部件:
我已经尝试设置固定大小和最小大小以及更改大小策略,但无论我做什么,一些小部件都会调整大小,有些会重叠,有些会被推到视野之外。
我正在使用设计器和 PyUIC。
如果有帮助,这是我的层次结构:
Qt 设计器层次结构:
设计者生成的 .ui 文件:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>299</width>
<height>478</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QScrollArea" name="scrollArea">
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>295</width>
<height>474</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>410</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="label_2">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>Select a .bed file to open</string>
</property>
</widget>
</item>
<item>
<widget class="BrowseForm" name="browseWidget"/>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Bead selection mode</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QRadioButton" name="radioStart">
<property name="text">
<string>Start</string>
</property>
<attribute name="buttonGroup">
<string notr="true">beadSelectionModeGroup</string>
</attribute>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radioInRangeStrict">
<property name="text">
<string>Strictly in range</string>
</property>
<attribute name="buttonGroup">
<string notr="true">beadSelectionModeGroup</string>
</attribute>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="radioInRange">
<property name="text">
<string>In range</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">beadSelectionModeGroup</string>
</attribute>
</widget>
</item>
<item row="1" column="3">
<widget class="QRadioButton" name="radioEnd">
<property name="text">
<string>End</string>
</property>
<attribute name="buttonGroup">
<string notr="true">beadSelectionModeGroup</string>
</attribute>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="radioMiddle">
<property name="text">
<string>Middle</string>
</property>
<attribute name="buttonGroup">
<string notr="true">beadSelectionModeGroup</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>150</height>
</size>
</property>
<property name="title">
<string>Colour options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QRadioButton" name="radioSingleColor">
<property name="text">
<string>Use single colour</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">colourButtonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioScoreColor">
<property name="text">
<string>Use score for colours</string>
</property>
<attribute name="buttonGroup">
<string notr="true">colourButtonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioColorColor">
<property name="text">
<string>Use colour from file</string>
</property>
<attribute name="buttonGroup">
<string notr="true">colourButtonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>92</height>
</size>
</property>
<property name="baseSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="page">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="topMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Colour</string>
</property>
</widget>
</item>
<item>
<widget class="QColourPicker" name="colorPicker">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="baseSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>n</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_9">
<property name="topMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QComboBox" name="scoreOrPercentile">
<item>
<property name="text">
<string>Score</string>
</property>
</item>
<item>
<property name="text">
<string>Percentile</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Colour gradient</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QLineEdit" name="startGradient">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item>
<widget class="QColourPicker" name="colorPickerStartGradient">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="baseSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>n</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLineEdit" name="endGradient">
<property name="text">
<string>1000</string>
</property>
</widget>
</item>
<item>
<widget class="QColourPicker" name="colorPickerEndGradient">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="baseSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>n</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="colourBlendCheckBox_2">
<property name="text">
<string>Use colour blend</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Conflict colour</string>
</property>
</widget>
</item>
<item>
<widget class="QColourPicker" name="conflictColorPicker_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="baseSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>n</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_3">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="colourBlendCheckBox">
<property name="text">
<string>Use colour blend</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Conflict colour</string>
</property>
</widget>
</item>
<item>
<widget class="QColourPicker" name="conflictColorPicker">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="baseSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>n</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Main model ID</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="mainModelId">
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>New model name</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="modelName">
<property name="text">
<string>bed_model</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="hideOrg">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Hide beads on main model</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="generateModelButton">
<property name="text">
<string>Generate Model</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QColourPicker</class>
<extends>QPushButton</extends>
<header>.qcolourpicker.h</header>
</customwidget>
<customwidget>
<class>BrowseForm</class>
<extends>QLineEdit</extends>
<header>.browseform.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>colourButtonGroup</sender>
<signal>buttonClicked(int)</signal>
<receiver>stackedWidget</receiver>
<slot>setCurrentIndex(int)</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>217</x>
<y>264</y>
</hint>
</hints>
</connection>
<connection>
<sender>colourBlendCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>label_4</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>81</x>
<y>215</y>
</hint>
<hint type="destinationlabel">
<x>74</x>
<y>222</y>
</hint>
</hints>
</connection>
<connection>
<sender>colourBlendCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>conflictColorPicker</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>111</x>
<y>215</y>
</hint>
<hint type="destinationlabel">
<x>104</x>
<y>245</y>
</hint>
</hints>
</connection>
</connections>
<buttongroups>
<buttongroup name="colourButtonGroup"/>
<buttongroup name="beadSelectionModeGroup"/>
</buttongroups>
</ui>
更新:非常感谢 quick 和全面的回答。对于后代,导致我出现问题的主要错误是我不知道将最小大小设置回 0x0 与重置它不同。重置我的滚动区域和组框的最小尺寸修复了它!
您已经为滚动区域的 scrollAreaWidgetContents
容器设置了最小高度。这导致覆盖容器的 minimumSizeHint
(这是使用其所有项目所需的最小大小计算的,并确保所有小部件都正确显示),因此滚动区域 forces 在达到最小高度之前,它会小于应有的高度,即使这会使某些小部件不可用甚至不可见。
完全重置 属性(使用最小尺寸字段的红色小箭头按钮),小部件将仅调整为它们自己的最小默认尺寸。
另请注意,您已经设置了许多其他大小相关的属性,除非确实需要,否则不应设置这些属性:
-
baseSize
property is only useful for top level windows and if the sizeIncrement
has been set, it's not the "suggested" size of the widget (that depends on the widget's sizeHint
;重置所有这些属性,因为它们对子小部件没有用;
- 重置所有设置为
0x0
的 minimumSize
属性,或者对于容器小部件,其设置的大小可能不允许其子项正确显示(与滚动区域);
- 重置大小策略覆盖,除非你真的知道它们是如何工作的;
- 重置间隔器的大小提示,因为堆叠式小部件已经处理了 所有 其页面所需的最小尺寸,因此对间隔器使用最小高度会导致有未使用的空格;
上面所有的重置指示都意味着使用小的红色箭头按钮,它实际上将属性重置为小部件的默认状态。请注意,手动 将值设置为默认值与重置它不同:属性的默认值可能取决于不同的方面,并且对于所有小部件和情况(包括 OS/style)可能并不相同,并且在使用默认值(属性 未设置)时确保 Qt 正确使用默认的预期行为,显式设置一个值即使 似乎是 默认值,也可能不会有相同的结果。
进一步的建议:
scrollAreaWidgetContents
已经设置了垂直布局,但您正在使用 进一步 几乎无用的嵌套垂直布局。将每个小部件从该嵌套布局移动到滚动区域的主要布局并删除该布局;
- 通常建议将表单布局用于扩展(也可能是动态)界面;你可以在底部使用普通的网格布局,因为它只包含 3 个小部件,你还应该设置复选框文本而不是使用标签(复选框的标准约定说它们的标签应该在右边);
- 检查 Tab 键顺序,因为看起来有点混乱;
我遇到了小部件和布局在我的滚动区域内开始重叠的问题。 我当前的布局应该是这样的:
我的布局:
但最终像这样,小部件开始重叠(这是固定大小的组框):
重叠示例:
或者这个(没有固定大小的分组框):
“Sqished”小部件并推出视图小部件:
我已经尝试设置固定大小和最小大小以及更改大小策略,但无论我做什么,一些小部件都会调整大小,有些会重叠,有些会被推到视野之外。
我正在使用设计器和 PyUIC。
如果有帮助,这是我的层次结构:
Qt 设计器层次结构:
设计者生成的 .ui 文件:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>299</width>
<height>478</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QScrollArea" name="scrollArea">
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>295</width>
<height>474</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>410</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="label_2">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>Select a .bed file to open</string>
</property>
</widget>
</item>
<item>
<widget class="BrowseForm" name="browseWidget"/>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Bead selection mode</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QRadioButton" name="radioStart">
<property name="text">
<string>Start</string>
</property>
<attribute name="buttonGroup">
<string notr="true">beadSelectionModeGroup</string>
</attribute>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radioInRangeStrict">
<property name="text">
<string>Strictly in range</string>
</property>
<attribute name="buttonGroup">
<string notr="true">beadSelectionModeGroup</string>
</attribute>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="radioInRange">
<property name="text">
<string>In range</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">beadSelectionModeGroup</string>
</attribute>
</widget>
</item>
<item row="1" column="3">
<widget class="QRadioButton" name="radioEnd">
<property name="text">
<string>End</string>
</property>
<attribute name="buttonGroup">
<string notr="true">beadSelectionModeGroup</string>
</attribute>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="radioMiddle">
<property name="text">
<string>Middle</string>
</property>
<attribute name="buttonGroup">
<string notr="true">beadSelectionModeGroup</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>150</height>
</size>
</property>
<property name="title">
<string>Colour options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QRadioButton" name="radioSingleColor">
<property name="text">
<string>Use single colour</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">colourButtonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioScoreColor">
<property name="text">
<string>Use score for colours</string>
</property>
<attribute name="buttonGroup">
<string notr="true">colourButtonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioColorColor">
<property name="text">
<string>Use colour from file</string>
</property>
<attribute name="buttonGroup">
<string notr="true">colourButtonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>92</height>
</size>
</property>
<property name="baseSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="page">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="topMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Colour</string>
</property>
</widget>
</item>
<item>
<widget class="QColourPicker" name="colorPicker">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="baseSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>n</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_9">
<property name="topMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QComboBox" name="scoreOrPercentile">
<item>
<property name="text">
<string>Score</string>
</property>
</item>
<item>
<property name="text">
<string>Percentile</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Colour gradient</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QLineEdit" name="startGradient">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item>
<widget class="QColourPicker" name="colorPickerStartGradient">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="baseSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>n</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLineEdit" name="endGradient">
<property name="text">
<string>1000</string>
</property>
</widget>
</item>
<item>
<widget class="QColourPicker" name="colorPickerEndGradient">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="baseSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>n</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="colourBlendCheckBox_2">
<property name="text">
<string>Use colour blend</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Conflict colour</string>
</property>
</widget>
</item>
<item>
<widget class="QColourPicker" name="conflictColorPicker_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="baseSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>n</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_3">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="colourBlendCheckBox">
<property name="text">
<string>Use colour blend</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Conflict colour</string>
</property>
</widget>
</item>
<item>
<widget class="QColourPicker" name="conflictColorPicker">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="baseSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>n</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Main model ID</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="mainModelId">
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>New model name</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="modelName">
<property name="text">
<string>bed_model</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="hideOrg">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Hide beads on main model</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="generateModelButton">
<property name="text">
<string>Generate Model</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QColourPicker</class>
<extends>QPushButton</extends>
<header>.qcolourpicker.h</header>
</customwidget>
<customwidget>
<class>BrowseForm</class>
<extends>QLineEdit</extends>
<header>.browseform.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>colourButtonGroup</sender>
<signal>buttonClicked(int)</signal>
<receiver>stackedWidget</receiver>
<slot>setCurrentIndex(int)</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>217</x>
<y>264</y>
</hint>
</hints>
</connection>
<connection>
<sender>colourBlendCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>label_4</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>81</x>
<y>215</y>
</hint>
<hint type="destinationlabel">
<x>74</x>
<y>222</y>
</hint>
</hints>
</connection>
<connection>
<sender>colourBlendCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>conflictColorPicker</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>111</x>
<y>215</y>
</hint>
<hint type="destinationlabel">
<x>104</x>
<y>245</y>
</hint>
</hints>
</connection>
</connections>
<buttongroups>
<buttongroup name="colourButtonGroup"/>
<buttongroup name="beadSelectionModeGroup"/>
</buttongroups>
</ui>
更新:非常感谢 quick 和全面的回答。对于后代,导致我出现问题的主要错误是我不知道将最小大小设置回 0x0 与重置它不同。重置我的滚动区域和组框的最小尺寸修复了它!
您已经为滚动区域的 scrollAreaWidgetContents
容器设置了最小高度。这导致覆盖容器的 minimumSizeHint
(这是使用其所有项目所需的最小大小计算的,并确保所有小部件都正确显示),因此滚动区域 forces 在达到最小高度之前,它会小于应有的高度,即使这会使某些小部件不可用甚至不可见。
完全重置 属性(使用最小尺寸字段的红色小箭头按钮),小部件将仅调整为它们自己的最小默认尺寸。
另请注意,您已经设置了许多其他大小相关的属性,除非确实需要,否则不应设置这些属性:
-
baseSize
property is only useful for top level windows and if thesizeIncrement
has been set, it's not the "suggested" size of the widget (that depends on the widget'ssizeHint
;重置所有这些属性,因为它们对子小部件没有用; - 重置所有设置为
0x0
的minimumSize
属性,或者对于容器小部件,其设置的大小可能不允许其子项正确显示(与滚动区域); - 重置大小策略覆盖,除非你真的知道它们是如何工作的;
- 重置间隔器的大小提示,因为堆叠式小部件已经处理了 所有 其页面所需的最小尺寸,因此对间隔器使用最小高度会导致有未使用的空格;
上面所有的重置指示都意味着使用小的红色箭头按钮,它实际上将属性重置为小部件的默认状态。请注意,手动 将值设置为默认值与重置它不同:属性的默认值可能取决于不同的方面,并且对于所有小部件和情况(包括 OS/style)可能并不相同,并且在使用默认值(属性 未设置)时确保 Qt 正确使用默认的预期行为,显式设置一个值即使 似乎是 默认值,也可能不会有相同的结果。
进一步的建议:
scrollAreaWidgetContents
已经设置了垂直布局,但您正在使用 进一步 几乎无用的嵌套垂直布局。将每个小部件从该嵌套布局移动到滚动区域的主要布局并删除该布局;- 通常建议将表单布局用于扩展(也可能是动态)界面;你可以在底部使用普通的网格布局,因为它只包含 3 个小部件,你还应该设置复选框文本而不是使用标签(复选框的标准约定说它们的标签应该在右边);
- 检查 Tab 键顺序,因为看起来有点混乱;