QGLWidget and renderText using Blending Problem [solved]

  • Hi everyone,

    I have a project with a 2D drawing engine using QPainter as default and QGLWidget with OpenGL as option (which has better performance).
    Now I had to implement a blending function to display semi transparent rectangles (this is new stuff). And I also draw text using the renderText() function of the QGLWidget (this is old stuff). The renderText function works fine so far, but I is not working with blending enabled.

    Here is an example: "Example":http://abload.de/image.php?img=exampleblipy.png

    Does anyone has an idea or a workaround?
    I figured out something about overpainting but I don't how?

    GLWidget inherits QGLWidget

    My code:

    glEnable( GL_BLEND );

    glBegin( GL_POLYGON );
    glVertex2f( x1, y1);
    glVertex2f( x1, y2 );
    glVertex2f( x2, y2 );
    glVertex2f( x2, y1 );

    glDisable( GL_BLEND );
    glBlendFunc( GL_SRC_ALPHA, GL_SRC_ALPHA );


    qglColor( Qt::black );
    renderText( x, y, text );


  • Hi everyone,

    as always it was my fault. That code above is not the whole code. I used glPolygonMode( GL_FRONT, GL_FILL ); to setup the fill mode of the Polygon. After drawing the polygon I reseted the polygonMode to GL_LINE, which is wrong. That causes the error.


  • Lifetime Qt Champion


    Glad you found out and thanks for sharing the solution !

    Can you also update the thread title prepending [solved] so other forum users may know a solution has been found :)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.