为什么我在 Qt Designer 中可以实现自适应窗口
生成代码运行后还是不能自适应
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(1042, 800)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.verticalLayout_2 = QtGui.QVBoxLayout(self.centralwidget)
self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.pushButton = QtGui.QPushButton(self.centralwidget)
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.verticalLayout.addWidget(self.pushButton)
self.pushButton_2 = QtGui.QPushButton(self.centralwidget)
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
self.verticalLayout.addWidget(self.pushButton_2)
self.pushButton_3 = QtGui.QPushButton(self.centralwidget)
self.pushButton_3.setObjectName(_fromUtf8("pushButton_3"))
self.verticalLayout.addWidget(self.pushButton_3)
self.horizontalLayout.addLayout(self.verticalLayout)
self.listView = QtGui.QListView(self.centralwidget)
self.listView.setObjectName(_fromUtf8("listView"))
self.horizontalLayout.addWidget(self.listView)
self.verticalLayout_2.addLayout(self.horizontalLayout)
# MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1042, 26))
self.menubar.setObjectName(_fromUtf8("menubar"))
# MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName(_fromUtf8("statusbar"))
# MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
self.pushButton.setText(_translate("MainWindow", "PushButton", None))
self.pushButton_2.setText(_translate("MainWindow", "PushButton", None))
self.pushButton_3.setText(_translate("MainWindow", "PushButton", None))