You are not logged in.


Thursday, February 2nd 2012, 12:16pm

QLinearGradients are not always drawn in OpenGL-accelerated QGraphicsView


I came across a compatibility problem with QLinearGradient in a hardware accelerated QGraphicsView, depending on the actual paint engine that is running. I know that in Qt 4.7.4, there are two different OGL paint engines available: the "old" QPaintEngine:: OpenGL, and the newer QPaintEngine:: OpenGL2 that can be run only on systems that have support for OpenGL 2.0 or higher.

The problem: If I draw a linear gradient on systems with bad OpenGL support (that is: on systems that run only with QPaintEngine:: OpenGL), the gradient is not drawn. See the attached images to see what it should look like (systemWithOpenGL20orHigher.png) and what I actually get on low spec systems (systemWithOpenGLLess20.png). Well, if it had been something really fancy that I draw, probably I wouldn't complain. But drawing rectangles with a gradient fill is so basic that I cannot understand why this should not be possible with the older paint engine...

Is there something special I have to consider? Any flags or settings I forgot about?

Find attached a minimal example that shows the problem on low spec machines.
For systems with OpenGL 2.0 support, everything goes fine for my example.

Note that the radial gradient always is drawn neatly because it gets rendered into a texture first which is sent to the GPU (a radial gradient is way too complex to draw with native OpenGL). I could work around my problem the same way, but this is very dissatisfactory!

Thanks for any response,
normiboy has attached the following files:


Thursday, March 1st 2012, 7:32am

Even though i have not debugged it right now but same issue is what i am facing in QML. Linear gradients does not work in Win Xp with declarative view set with GlWidget as viewport.