在学习Qt的过程中,我遇到了一个错误AttributeError:“Ui\u MainWindow”对象没有属性“setupUI”
代码显示如下:
# This Python file uses the following encoding: utf-8
import sys
from windowUI import Ui_MainWindow
from PySide2.QtWidgets import Application, QMainWindow
if __name__ == "__main__":
app = Application([])
aw = Ui_Mainwindow()
window = OMainwindow()
aw.setupUI(window)
window. show()
sys.exit(app.exec_())
以下代码是。py文件由生成。用户界面
class Ui_MainWindow(object):
def setupui(self, Mainwindow):
Mainwindow.setobjectName("MainWindow")
Mainwince.resize(800, 600)
MainWinauw.setLayoutDirection(QtCore.Qt.RightToLeft)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setobjectName("centralwidget")
self.commandLinkButton = Qtwidgets.QCommandLinkButton(self. centralwidget)
self.commandLinkButton.setGeometry(QtCore.QRect(330, 230, 187, 41))
self.commandLinkButton.set0bjectName("commandLinkButton")
MainWindow.setCentralwidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(@tCore.QRect (0, 0, 800, 27))
self.menubar.set0bjectName("menubar")
Mainwindow.setMenuBar(self. menubar)
self.statusbar = Qtwidgets.QStatusBar(MainWindow)
self.statusbar.setobjectName("statusbar")
Mainwindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetalbject.connectSlotsByName(MainWindow)
def retranslateli(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
Mainwindow.setwindowTitle(_translate("MainWindow",
"MainWindow"))
self.commandLinkButton.setText(_translate("MainWindow","test"))