Advertisement

Python出现错误:在MainWindow对象中无法获取属性setCentralWidget

阅读量:

python相关报错总结

  • AttributeError: 'MainWindow' object has no attribute 'setCentralWidget'

AttributeError: ‘MainWindow’ object has no attribute ‘setCentralWidget’

翻译:AttributeError:“ MainWindow”对象没有属性“ setCentralWidget”
实例:

复制代码
    from window import Ui_MainWindow
    import sys
    from PyQt5 import QtWidgets
    
    class MainWindow(Ui_MainWindow,QtWidgets.QWidget):
    def __init__(self):
        super(MainWindow,self).__init__()
        self.setupUi(self)
    
    
    if __name__ =='__main__':
    app = QtWidgets.QApplication(sys.argv)
    mywindow = MainWindow()
    mywindow

全部评论 (0)

还没有任何评论哟~