From the documentation:
This function can only be used inside the QPainter :: beginNativePainting () / QPainter :: endNativePainting () block, if the default OpenGL paint engine is QPaintEngine :: OpenGL. To force QPaintEngine :: OpenGL to use the default GL mechanism, call QGL :: setPreferredPaintEngine (QPaintEngine :: OpenGL) before the QApplication constructor.
Therefore, did you try to use QPainter::beginNativePainting() just before the call and QPainter::endNativePainting() right after?
Also note that the text is displayed in the window coordinate, not taking into account your current state of the OpenGL matrix (in short, your call to glRotatef(90, 0, 0, 1) does not affect). You can see in here to save the current state of OpenGL by calling qt_save_gl_state() , then create their new matrices with:
glMatrixMode(GL_PROJECTION); glLoadIdentity(); glViewport(0, 0, width, height); glOrtho(0, width, height, 0, 0, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity();
Then draw the text and finally restore the previous OpenGL state with qt_restore_gl_state()
source share