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.
{
Q_OBJECT
/* code */
protected:
/* more code */
};
static void drawBackGround
(QPainter *painter
) {
painter->setPen(Qt::NoPen);
painter->setBrush(mBackground); /* some brush for my background */
painter->drawRect(rect());
}
{
Q_UNUSED(event)
drawBackGround(&painter);
draw(); // openGL calls
event->setAccepted(true);
}
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);
}
To copy to clipboard, switch view to plain text mode
Bookmarks