Skip to content

Commit 929d8d4

Browse files
committed
QVBoxLayout
1 parent 978c968 commit 929d8d4

File tree

6 files changed

+120
-0
lines changed

6 files changed

+120
-0
lines changed
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>BaseVerticalLayout</class>
4+
<widget class="QWidget" name="BaseVerticalLayout">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>400</width>
10+
<height>300</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Form</string>
15+
</property>
16+
<layout class="QVBoxLayout" name="verticalLayout">
17+
<item>
18+
<widget class="QLabel" name="label">
19+
<property name="text">
20+
<string>通过 右键 -&gt; 布局 -&gt; 垂直布局</string>
21+
</property>
22+
<property name="alignment">
23+
<set>Qt::AlignCenter</set>
24+
</property>
25+
</widget>
26+
</item>
27+
<item>
28+
<widget class="QPushButton" name="pushButton">
29+
<property name="text">
30+
<string>底部按钮</string>
31+
</property>
32+
</widget>
33+
</item>
34+
</layout>
35+
</widget>
36+
<resources/>
37+
<connections/>
38+
</ui>
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>VerticalLayoutMargin</class>
4+
<widget class="QWidget" name="VerticalLayoutMargin">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>400</width>
10+
<height>300</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Form</string>
15+
</property>
16+
<property name="styleSheet">
17+
<string notr="true">#VerticalLayoutMargin {
18+
background: #5aaadb;
19+
}
20+
#label {
21+
background: #85c440;
22+
}</string>
23+
</property>
24+
<layout class="QVBoxLayout" name="verticalLayout">
25+
<property name="spacing">
26+
<number>50</number>
27+
</property>
28+
<property name="leftMargin">
29+
<number>20</number>
30+
</property>
31+
<property name="topMargin">
32+
<number>20</number>
33+
</property>
34+
<item>
35+
<widget class="QLabel" name="label">
36+
<property name="text">
37+
<string>通过设置Margin和Spacing设置边距以及两个控件之间的间隔距离</string>
38+
</property>
39+
<property name="alignment">
40+
<set>Qt::AlignCenter</set>
41+
</property>
42+
</widget>
43+
</item>
44+
<item>
45+
<widget class="QPushButton" name="pushButton">
46+
<property name="text">
47+
<string>Spcasing 为 50</string>
48+
</property>
49+
</widget>
50+
</item>
51+
<item>
52+
<widget class="QPushButton" name="pushButton_2">
53+
<property name="text">
54+
<string>Spcasing 为 50</string>
55+
</property>
56+
</widget>
57+
</item>
58+
</layout>
59+
</widget>
60+
<resources/>
61+
<connections/>
62+
</ui>

QVBoxLayout/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# QVBoxLayout
2+
3+
- 目录
4+
- [垂直布局](#1垂直布局)
5+
- [边距和间隔](#2边距和间隔)
6+
7+
## 1、垂直布局
8+
[查看 BaseVerticalLayout.ui](Data/BaseVerticalLayout.ui)
9+
10+
![BaseVerticalLayout](ScreenShot/BaseVerticalLayout.png)
11+
12+
## 2、边距和间隔
13+
[查看 VerticalLayoutMargin.ui](Data/VerticalLayoutMargin.ui)
14+
15+
1. 通过`setContentsMargins(20, 20, -1, -1)`设置左上右下的边距,-1表示默认值
16+
2. 通过`setSpacing``subControlRect`设置控件之间的间隔
17+
18+
![VerticalLayoutMargin](ScreenShot/VerticalLayoutMargin.png)
5.03 KB
Loading
31.5 KB
Loading

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ https://pyqt.site 论坛是专门针对PyQt5学习和提升开设的网站,分
2121

2222
- Layouts
2323
- [QVBoxLayout](QVBoxLayout)
24+
- [垂直布局](QVBoxLayout#1垂直布局)
25+
- [边距和间隔](QVBoxLayout#2边距和间隔)
2426
- [QHBoxLayout](QHBoxLayout)
2527
- [QGridLayout](QGridLayout)
2628
- [腾讯视频热播列表](QGridLayout/HotPlaylist.py)

0 commit comments

Comments
 (0)