I am working with python code generated using QT Designer. I want to open a new dialogue from a button on my MainWindow. When I use the following code, the dialogue window disappears as soon as it is created. I assume this is because the QDialog object is destroyed when the method hits the return statement. What is the right way to call this dialogue?
def OpenDialogue(self):
DialogueWindow = QtGui.QDialog()
my_dialogue = MyDialogue.Ui_Dialog()
my_dialogue.setupUi(DialogueWindow)
DialogueWindow.show()
return
For example, should I instantiate DialogueWindow in the same place that I define MainWindow and pass it through to this method?
The MainWindow constructor is as follows:
class Ui_MainWindow(QtGui.QMainWindow, object):
def setupUi(self, MainWindow):
[code]
It is instantiated as follows:
app = QtGui.QApplication(sys.argv)
MainWindow = QtGui.QMainWindow()
ui = GUI.Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
app.exec_()