I am trying to find a way to change the default value for a font string string using QFont , QFontMetrics or something like that. I am using QPainter::drawText to draw some text in a bounding box.
It is strange that QFont allows QFont to change the font of kerning and even has some stretching operation and the distance between the letters, but nothing to change the default space between the lines. I searched and found some partial solutions using QTextLayout , but none of them worked properly.
I need to use QPainter because I am creating a texture with text that will be displayed using OpenGL.
Looking for more ideas for me to try!
UPDATE
I found that I can use QPainter to draw a QStaticText , which allows you to format text in HTML format, similar to QTextDocument . However, CSS styling does not work, as in QTextDocument (there is an error report there) ... Therefore, there is still no lead, but I hope this puts me on the right track.
solvable
I got what I wanted to use QTextDocument , as Michaelo suggested. Solution Link
source share