Skip to content Skip to sidebar Skip to footer

PyQt4:Can‘t Open My Dialog When I Write My First Code

I want to build a dialog with the PyQt4.My compile envirenment is Qt4,Python2 and PyQt4. I have done something for my job. 1.I complete my UI with Qt Designer and the ui file named

Solution 1:

With this method of using Qt Designer created python files, generally, your class will inherit the Ui_Dialog class.

class ChatDialog(QtGui.QDialog, Ui_Dialog):

    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)                
        self.setupUi(self)

Sometimes, people won't inherit, but will assign it to an attribute of the class:

class ChatDialog(QtGui.QDialog):

    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)                
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)

Post a Comment for "PyQt4:Can‘t Open My Dialog When I Write My First Code"