在Qt Designer中,我可以看到
verticalLayout
有一个默认的边距(13px),但是pyuic5总是给我self.verticalLayout.setContentsMargins(0, 0, 0, 0)
。在uiparser.py:443
中,我找到了这个评论:它将边距设置为默认情况下,布局小部件不应该有边距。
(0,0,0,0)
。另一个注释也说:这是什么意思?我正在使用PyQt-5.7,并且这是我的ui文件:除非父窗口是QMainWindow,否则普通QWidget是布局窗口小部件。请注意,相应的uic测试更加复杂,因为它涉及到pyuic不支持的功能。
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>configDialog</class>
<widget class="QDialog" name="configDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>566</width>
<height>552</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="general">
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
*.setContentsMargins(0, 0, 0, 0)
。很不错的bug,为什么它不能将它们设置为-1呢? - krrr