PDA

View Full Version : Double Buffering on QGLWidget - Background always grey



StarShaper
31st March 2012, 17:35
Hi,

I would like to do double buffering on QGLWidget. I already did that on QWidget and it worked perfectly. I have a QPixmap and i call a function, to draw some stuff to the pixmap.


func()
{
m_pixmap = QPixmap(size());
m_pixmap.fill(this, 0, 0);

QPainter painter(&m_pixmap);
painter.setRenderHint(QPainter::Antialiasing);
painter.initFrom(this);
// drawing

In my paintEvent() function I do:


QStylePainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.drawPixmap(0, 0, m_pixmap);

But when I do this, my bachground is always grey. The OpenGL background is overpainted.

Any ideas why? And how can I fix this?

If I draw my objects in paintEvent directly it works. But I would like to draw the pixmap.

Added after 23 minutes:

Solved! I had to set the QPixmap transparent.


m_pixmap.fill(Qt::transparent);