Hi everyone.
I am making a GUI application using python3.4, PyQt5 in windows 7.
Application is very sample. User clicks a main window's button, information dialog pops up. And when a user clicks information dialog's close button (window's X button), system shows confirm message. This is all.
Here's my code.
# coding: utf-8import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QDialog, QLabelclass mainClass(QMainWindow):def __init__(self):super().__init__()self.initUI()def initUI(self):openDlgBtn = QPushButton("openDlg", self)openDlgBtn.clicked.connect(self.openChildDialog)openDlgBtn.move(50, 50)self.setGeometry(100, 100, 200, 200)self.show()def openChildDialog(self):childDlg = QDialog(self)childDlgLabel = QLabel("Child dialog", childDlg)childDlg.resize(100, 100)childDlg.show()if __name__ == "__main__":app = QApplication(sys.argv)mc = mainClass()sys.exit(app.exec_())
Result screen shot is...
In this situation, I've added these code in mainClass class.
def closeEvent(self, event):print("X is clicked")
This code works only when the main window is closed. But what I want is closeEvent function works when childDlg is to closed. Not main window.
What should I do?