From 1cc671be199819ecc1adf5e3e43a6c7baba934c1 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sun, 22 Sep 2013 10:36:25 -0500 Subject: [PATCH] fixes issue with using transparency for the figure patch and being able to see shadows of previous draws underneath. see: http://stackoverflow.com/questions/18944561/matplotlib-pyqt4-transparent-figure Added some documentation to `paintEvent` --- lib/matplotlib/backends/backend_qt4agg.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/matplotlib/backends/backend_qt4agg.py b/lib/matplotlib/backends/backend_qt4agg.py index 659f4a8ddae1..e1014e5f5661 100644 --- a/lib/matplotlib/backends/backend_qt4agg.py +++ b/lib/matplotlib/backends/backend_qt4agg.py @@ -102,10 +102,16 @@ def paintEvent( self, e ): refcnt = sys.getrefcount(stringBuffer) + # convert the Agg rendered image -> qImage qImage = QtGui.QImage(stringBuffer, self.renderer.width, self.renderer.height, QtGui.QImage.Format_ARGB32) + # get the rectangle for the image + rect = qImage.rect() p = QtGui.QPainter(self) + # reset the image area of the canvas to be the back-ground color + p.eraseRect(rect) + # draw the rendered image on to the canvas p.drawPixmap(QtCore.QPoint(0, 0), QtGui.QPixmap.fromImage(qImage)) # draw the zoom rectangle to the QPainter