How to detect dialog's close event?
<p><br>
Hi everyone.</p>

<p>I am making a GUI application using python3.4, PyQt5 in windows 7. </p>

<p>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.</p>

<p>Here's my code.</p>

<pre><code># coding: utf-8

import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QDialog, QLabel

class 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_())
</code></pre>

<p>Result screen shot is...</p>

<p><a href="https://i.stack.imgur.com/dBQnR.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/dBQnR.jpg" alt="enter image description here"></a></p>

<p><a href="https://i.stack.imgur.com/lzE14.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/lzE14.jpg" alt="enter image description here"></a></p>

<p>In this situation, I've added these code in mainClass class.</p>

<pre><code>def closeEvent(self, event):
    print("X is clicked")
</code></pre>

<p>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.</p>

<p>What should I do?</p>