[Qt-interest] Drawing text over a QGLWidget

Alan Norton alan at ucar.edu
Fri Jan 29 19:55:58 CET 2010


Donal,
Thanks for your suggestion, however, there are some problems with using 
QGLWidget::renderText(), at least in QT4.6.
There are some OpenGL resources that are not being released (even if I 
do glDeleteLists() ) resulting in a crash on exit (on Linux) and other 
warning messages on Windows.  There were some messages about this in 
this maillist, but there was no resolution.

Also, another serious problem is that the text quality from renderText 
is poor unless I make the text very big.  The letters get cropped if the 
text is small.

With QT3.3, I used to use QLabels over QGLWidgets, and the quality was 
very good.  But this doesn't work in QT4.6 as far as I can tell.
-Alan

Donal O'Connor wrote:
> After you've everything in your scene rendered in the paintGL method, 
> you should call renderText.
>
> eg:
>
> renderText(-20.0,-20.0,0.0,QString("Hi There"), QFont("Arial", 20, 5, 
> false));
>
> and then to stop flickering,
>
> place following lines after before end method:
>
> swapBuffers();
> glFlush();
>
> On Wed, Jan 27, 2010 at 4:43 PM, Alan Norton <alan at ucar.edu 
> <mailto:alan at ucar.edu>> wrote:
>
>     I would like to draw text at specified coordinates over an image
>     rendered in a QGLWidget.  This is in QT4.6.
>     I want the text and the image to be visible at the same time.
>     I tried using QPainter::drawText() in the paintGL() method, and in the
>     PaintEvent() method.  In the first case, the entire GL scene was
>     overwritten.  In the second case, the painting never stops, flickering
>     all the time.  Surely there is a "right" way to do this, but I
>     couldn't
>     see any examples of this.  Any ideas are welcome.
>     Thanks,
>     -Alan Norton
>     _______________________________________________
>     Qt-interest mailing list
>     Qt-interest at trolltech.com <mailto:Qt-interest at trolltech.com>
>     http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>



More information about the Qt-interest-old mailing list