关于某个PyQt5系列教程“'QMainWindow' object has no attribute”的错误修正

来源:互联网 发布:什么数据库8000多 编辑:程序博客网 时间:2024/06/14 15:33

原文地址:http://www.cnblogs.com/tkinter/p/5632245.html

一直到运行main程序之前之前都没有什么错误;

但是运行后出错:

python IDLE报错:

self.pushButton.clicked.connect(MainWindow.firstPyQt5_button_click)
AttributeError: 'QMainWindow' object has no attribute 'firstPyQt5_button_click'

改正方法:将firstPyQt5.py中的self.pushButton.clicked.connect(MainWindow.firstPyQt5_button_click)

更正为:self.pushButton.clicked.connect(self.firstPyQt5_button_click)

错误原因:不能完全说是教程错误,感觉也有可能是自己操作问题

根本原因就是因为传参错误,将窗口本身的函数赋值给了父类的MainWindow(python学的不精,个人猜测)

欢迎拍砖

阅读全文
0 0