title: using weakref to get exit child windows in PyQt4
body: <p>I am trying to take advantage of weakref.ref that if the main window object is deleted then the child window should close with it.</p>
  
  <p>Here is the example I have tried, but is not working as expected :</p>
  
  <pre><code>import sys
  import weakref
  from PyQt4 import QtCore, QtGui
  
  print __file__
  
  class ParentWindow(QtGui.QMainWindow):
      """docstring for ParentWindow"""
      def __init__(self, parent=None):
          super(ParentWindow, self).__init__(parent)
          self.setWindowTitle("Parent Window")
          self.setGeometry(300, 300, 250, 150)
          self._setupUi()
          self._connections()
          self.childObj = ChildWindow()
          self.uiDict = weakref.ref(self, self._closeChild)
  
      def _closeChild(self):
          self.childObj.close()
  
      def _setupUi(self):
          self.btn = QtGui.QPushButton("Launch child window in child thread")
          self.setCentralWidget(self.btn)
  
  
      def _connections(self):
          self.btn.clicked.connect(self.callChild)
  
      @QtCore.pyqtSlot()
      def callChild(self):
          self.childObj.show()
  
  class ChildWindow(QtGui.QWidget):
      def __init__(self, parent=None):
          super(ChildWindow, self).__init__(parent)
          self.setWindowTitle("Child Window")
          self.byeBtn = QtGui.QPushButton("Bye", self)
          self.childLayout = QtGui.QVBoxLayout()
          self.childLayout.addWidget(self.byeBtn)
          self.setLayout(self.childLayout)
          self.byeBtn.clicked.connect(self.close)
  
      def __del__(self):
          print "Exiting"
  
  def main():
      app = QtGui.QApplication(sys.argv)
      app.setApplicationName('Parent')
      pWinObj = ParentWindow()
      pWinObj.show()
  
      sys.exit(app.exec_())
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>right now when I am closing the main window its not happening. </p>