How to render text in scene graph?



  • Hi,

    I am writing a custom QQuickItem with QSGGeometry-based rendering (ie not using QPainter) and I need to render text. Is this possible and how?

    I've thought about using Text elements in QML and having my item send signals to position it, but this is extremely brittle and messy and impossible when geometry should be obscuring text, so I want to perform the text rendering using scene graph. I didn't see anything in the docs about how one would do this, however.



  • Nobody knows how to do this?

    I'd like to avoid manually rendering text in OpenGL, since I don't want to duplicate code (QtQucik already has a text rendering subsystem built in afterall)...



  • I had the same issue and finally found out that dynamically instantiating and placing QML Text elements in updatePolish() method does the work pretty well. Don't forget to call polish() whenever your text elements need to be updated though. Also try creating objects only when needed and then only change properties on stored references for better performance.



  • Hi @unai_i, i know this is very old thread, can you please provide simple code on how to render text using updatePolish() in scene graph? Thanks.


Log in to reply
 

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