You are not logged in.

Dear visitor, welcome to If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.


Tuesday, September 18th 2012, 12:20pm

QPainter, opengl and depth test

Hi all,

in my program there are stuff that are being painted in the opengl area with native opengl commands (glMatrixMode, glEnable etc.). There are also few things that are painted using a QPainter. My problem now is that i don't know how to enable the depth test (glEnable(GL_DEPTH_TEST)) for that QPainter. In the documentation of QPainter i've seen there are the functions "beginNativePainting" and "endNativePainting" but if i call beginNativePainting and enable the depth test, then, in order to use the QPainter, i must first call endNativePainting which will reset the depth test (as i can read from the assistant). But even if this state isn't reset with the current release of Qt, noone guarrantees me it's state in a following release of Qt (again, reading from the assistant). What should i do in order to correctly enable the depth-test and, of course, set the Z coordinate?
Thanx in advance

p.s. i use a function which takes coordinates from the 3D system (x,y,z) and gives me the 2D projection (x,y) which i use for the QPainter.


Tuesday, October 2nd 2012, 7:50am

I think there's no solution to my problem, so the only way to continue is to draw them with native opengl code.

Similar threads

Used tags

DEPTH_TEST, OpenGL, QPainter