AttributeError: ‘AppearanceInspection’ object has no attribute ‘toolBar’
请你一定一定一定一定一定要注意,如果你在qt设计师设计好界面之后,你还自己在python中添加了比如工具栏self.toolBar,那么你直接在:
class AppearanceInspection(Ui_AppearanceInspection, QMainWindow,object):
def __init__(self):
super().__init__()
self.setupUi(self)
self.init()
def init(self):
# 定时器让其定时读取显示图片
self.camera_timer = QTimer()
# 这是照相机实时显示的原因
self.camera_timer.timeout.connect(self.show_image)
# 打开文件夹
self.pushButton_openidr.clicked.connect(self.openimage)
# 测试
self.pushButton_test.clicked.connect(self.corp_test)
self.toolBar.actionTriggered[QtWidgets.QAction].connect(self.getvalue)
这么去写一定会出问题,初始化记住一定要写在所有窗口属性的最后面。提前self.init(),其中的函数会找不到对应属于而报错
self.init()可以初始化init函数的函数。
本文含有隐藏内容,请 开通VIP 后查看