PDA

View Full Version : Display a Label on top of a QGlWidget



Lele
4th February 2008, 11:34
Hi,
I would like to display a QLabel (basically just a text) on top of an QGlWidget.
In paintGL() I render my OpenGL stuff, I would like to have a number displayed over the OpenGL context.
I tried overriding paintEvent but I think the Gl context is always on top.
Any idea?

Thanks in advance



void Player::paintEvent(QPaintEvent *event)
{

QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.drawText(250, 250, "1");
QGLWidget::paintEvent(event);
}

aamer4yu
4th February 2008, 11:38
I am not much aware of OpenGL, but will changing the order help you ??


QGLWidget::paintEvent(event);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.drawText(250, 250, "1");
:confused:

Lele
4th February 2008, 11:55
No, in fact before I put
QGLWidget::paintEvent(event); at the beginning.
It's displayed just few seconds before the OpenGL start rendering.

Lele
4th February 2008, 16:11
Maybe should I use something else rather than QLabel?
Any idea?
Thanks