刚开始学习PyQt5 就遇到问题,有哪位大神指点一下我!!!
import sys
import first
from PyQt5.QtWidgets import QApplication,QMainWindow
if __name__ == "__main__":
app=QApplication(sys.argv)
mainwindow=QMainWindow()
ui=first.Ui_Dialog()
ui.setupUi(mainwindow)
mainwindow.show()
sys.exit(app.exec_())
报错如下:
File “f:/Python/画图/画图工具方法.py”, line 11, in
ui.setupUi(mainwindow)
File “f:\Python\画图\first.py”, line 36, in setupUi
self.buttonBox.accepted.connect(Dialog.accept)
AttributeError: ‘QMainWindow’ object has no attribute ‘accept’
由ui文件 变换过来的py(first.py)文件如下:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'F:\Python\画图\first.ui'
#
# Created by: PyQt5 UI code generator 5.13.0
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, Qt