QwtPolarPlot transparency and CSS

Automatically generated description.

Apparently, you can’t use transparency for QwtPolarPlot now (as for qwtpolar-0.1.0).

When you try to set transparent background for QwtPolarPlot:
app.setStyleSheet("QwtPolarPlot {background: transparent}");
<p>you could see this:<br />


Not very nice, yeah?

This is happenning because QwtPolar library is using some fancy technique for caching.


So, how to fix it? Well, quick fix would be to redefine QwtPolarCanvas::drawCanvas method within your application and comment out that fancy code:
void QwtPolarCanvas::drawCanvas(QPainter *painter,
    const QwtDoubleRect& canvasRect) {
  if ( !canvasRect.isValid() )
           return;
  plot()->drawCanvas(painter, canvasRect);
}
So, the problem is solved:


<img alt="" src="http://dl.dropbox.com/u/4217195/vanuan.heroku.com/2.png" style="width:200px; height:200px;" />


You can stop there, but what if you&#8217;re a perfectionist? :)


Let&#8217;s look what&#8217;t happenning. The problem is here:
painter->drawPixmap(canvasRect.topLeft().toPoint(), *d_data->cache);
Somehow, QPixmap is not transparent. The solution is to do this:
       QBitmap mask(d_data->cache->size());
        mask.clear();
        d_data->cache->setMask(mask);
or that:
 d_data->cache->fill(Qt::transparent);
before calling
plot()->drawCanvas(painter, canvasRect);
**Edit**. Calling plot-&gt;canvas()-&gt;invalidatePaintCache() every time the plot is changed solves this problem without workaround.


<ul>
	- [Qwt and transparency](http://www.qtforum.org/article/16586/qpainter-problem.html)
	- [QPixmap transparent](http://lists.trolltech.com/qt-interest/2006-09/msg00990.html)
</ul>