Important: Please read the Qt Code of Conduct -

Rendering text with QGraphicsScene set to OpenGl

  • Hi,

    I initially created a QGLWidget which did all my openGl painting. Using that widget I had access to the renderText function which made drawing text trivial.

    Due to the requirements of what I am doing I have now switched to using a QGraphicsView with the viewport set to a QGLWidget. All my OpenGl drawing now takes place in the drawBackground function of the QGraphicsScene, which means I no longer have access to the renderText function.

    Can someone suggest a way to easily drawText within the drawBackground function of the QGraphicsScene?



  • In the draw background method , you can render the text by calling drawText() method .. Along with it you have to set a font for the painter in which the font has reasonable fontstretch and pointsize

Log in to reply