title: Set parent of matplotlib figure
body: <p>I have a problem with setting the figure generated by the following code. It does not close when the mainwindow is closed. I have used <code>self.setAttribute(Qt.WA_DeleteonClose)</code> in the mainwindow. The mainwindow object is passed as parent while calling the <code>smd</code> function. Even though, I have explicitly set the parent of canvas, Figure generated is not closed when mainwindow is closed.</p>
  
  <pre><code>def smd(self,parent):
  
      from pylab import *
      import matplotlib
  
      from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
  
      from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar
  
      from matplotlib.figure import Figure
      import pylab as p
  
      sm = [1,2,3]
      fig = p.figure()
  
      ax = fig.add_subplot(111)
      ax.bar(range(len(sm)),sm,align='center')
      ax.set_xticks(range(len(sm)))
  
      canvas = FigureCanvas(fig)
      canvas.setParent(parent)
      #p.setParent(self)
      canvas.draw()
      fig.setParent(parent)
      print "parent is ", parent, canvas.parent()
  
      p.show()
  </code></pre>