PDA

View Full Version : Problem with QGLWidget paint events in Qt 4.6



Wali
10th December 2009, 22:13
I recently updated my Qt 4.3 to 4.6. With that said, in my QGLWidget sub class I reimplemented the paint event where a background brush was drawn using QPainter. Then I would call my OpenGL calls to draw over the background. This worked perfectly in earlier versions of Qt, but 4.6 seems to just draw over my OpenGL graphics.

I understand that the OpenGL paint system has been overhauled in this release. But I really need this functionality to work in this version and any future releases. Any help would be appreciated. Thanks.

Here is a snippet of my code.


class gfx : public QGLWidget
{
Q_OBJECT
/* code */
protected:
void paintEvent(QPaintEvent *event);
/* more code */
};

static void drawBackGround(QPainter *painter)
{
painter->setPen(Qt::NoPen);
painter->setBrush(mBackground); /* some brush for my background */
painter->drawRect(rect());
}
void gfx::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);

drawBackGround(&painter);

draw(); // openGL calls
event->setAccepted(true);
}

Grimlock
11th December 2009, 10:41
Have You tried using void QGLWidget::qglClearColor ( constQColor& c) const