没有加底部布局之前如图:
加了底部布局之后:
代码如图:
main.js封装:
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication
from Ui_MainWindow import *
class Demo(QMainWindow, Ui_MainWindow):
def __init__(self):
super(Demo, self).__init__()
# 将UI界面布局到Demo上;
self.setupUi(self)
if __name__ == '__main__':
app = QApplication(sys.argv)
demo = Demo()
demo.show()
sys.exit(app.exec_())
部分UI转换成的py代码:
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(942, 666)
# 定义的底层栅格布局
self.gridLayout_main = QtWidgets.QGridLayout(MainWindow)
self.gridLayout_main.setContentsMargins(15, -1, -1, -1)
self.gridLayout_main.setVerticalSpacing(20)
self.gridLayout_main.setObjectName("gridLayout_main")
# 子布局之一
self.gridLayout_3 = QtWidgets.QGridLayout()
self.gridLayout_3.setObjectName("gridLayout_3")
self.verticalLayout_4 = QtWidgets.QVBoxLayout()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…