Pyqt5 NameError

前端 未结 1 1473
时光取名叫无心
时光取名叫无心 2021-01-21 11:07

I am trying to find why this gives me a NameError.... Class name App(QDialog): is the one that has the error. I was following exactly as youtube video, while his co

相关标签:
1条回答
  • 2021-01-21 11:48
    NameError: name 'QDialog' is not defined
    

    You are getting this error because you forgot to import QDialog. Just add it to the end of one of your QWidgets imports such as:

    from PyQt5.QtWidgets import QInputDialog, QLineEdit, QDialog
    

    Also, you are going to get an attribute error because self.top is called, but never defined. Add it in the init function:

    def __init__(self):
        super().__init__()
        self.title = "PyQt5 example - pythonspot.com"
        self.left = 10
        self.right = 10
        self.width = 640
        self.height = 400
        self.top = 10
        self.initUI()
    
    0 讨论(0)
提交回复
热议问题