pyqt designer使用spliter

1、在designer界面需要使用spliter需要父界面不使用布局,减需要分割两个模块选中,再点击spliter分割
在这里插入图片描述
2、在分割后,再对父界面进行布局设置
3、对于两边需要不等比列放置的,需要套一层 group box在最外层进行分割
在这里插入图片描述

使用PyQt Designer可以方便地实现嵌套布局,如网格布局、水平布局、垂直布局等。下面是一个简单的示例,用于演示如何使用PyQt Designer进行布局: 1. 打开PyQt Designer,选择“Main Window”模板,创建一个新的窗口。 2. 在窗口中添加一个QVBoxLayout布局,用于垂直排列组件。 3. 在QVBoxLayout布局中添加一个QHBoxLayout布局,用于水平排列组件。 4. 在QHBoxLayout布局中添加一个QLabel和一个QLineEdit组件。 5. 在QVBoxLayout布局中添加一个QTextEdit组件。 6. 在QVBoxLayout布局中添加一个QPushButton组件,并将其设置为居中对齐。 7. 保存并运行该窗口,查看布局效果。 以下是示例代码,您可以在PyQt Designer中打开.ui文件并通过拖放组件来创建布局: ```xml <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class> <widget class="QMainWindow" name="MainWindow"> <widget class="QWidget" name="centralwidget"> <layout class="QVBoxLayout" name="verticalLayout"> <item> <layout class="QHBoxLayout" name="horizontalLayout"> <item> <widget class="QLabel" name="label"> <property name="text"> <string>Label:</string> </property> </widget> </item> <item> <widget class="QLineEdit" name="lineEdit"/> </item> </layout> </item> <item> <widget class="QTextEdit" name="textEdit"/> </item> <item> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>0</width> <height>40</height> </size> </property> <property name="sizePolicy"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> </spacer> </item> <item> <widget class="QPushButton" name="pushButton"> <property name="text"> <string>Button</string> </property> <property name="sizePolicy"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="layoutDirection"> <enum>Qt::LeftToRight</enum> </property> <property name="autoDefault"> <bool>true</bool> </property> <property name="default"> <bool>true</bool> </property> <property name="flat"> <bool>false</bool> </property> <property name="checkable"> <bool>false</bool> </property> <property name="autoRepeat"> <bool>false</bool> </property> <property name="autoExclusive"> <bool>false</bool> </property> <property name="default"> <bool>false</bool> </property> <property name="autoRepeatDelay"> <number>0</number> </property> <property name="autoRepeatInterval"> <number>0</number> </property> </widget> </item> </layout> </widget> </widget> <resources/> <connections/> </ui> ``` 注意:为了使QPushButton组件在布局中居中对齐,我们需要手动设置它的属性。在上面的示例中,我们将QPushButton的“sizePolicy”属性的“vsizetype”设置为“Fixed”,并将“sizeHint”调整为合适的高度值(这里设置为40)。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值