Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Qt::TextFlag vs. QTextOption
Asperamanca last edited by
I am slightly confused about the use of Qt::TextFlag versus QTextOption.
I am preparing a QStaticText, that can either be single line or multi line.
QStaticText::size() is unreliable in certain circumstances (so far, it returns incorrect results on a Windows 7 machine, with the font size given in Pixels, not Point).
Therefore, I am trying to calculate the size using good old QFontMetrics.
Now, QStaticText uses the QTextOption object, so I have a QTextOption object ready for use.
However, QFontMetrics wants Qt::TextFlag.
Is there a way to translate one to the other, or do I have to do it by hand (as far as the flags match at all)?
BilbonSacquet last edited by
The big difference between both approach is the technology used:
QStaticText use internally a QTextDocument to layout, so mainly the interface need a QTextCharFormat and a QTextOption to format the text (mainly rich text).
In the case of the font based fonction like, drawText() or QFontMetrics class they are using a simplier layout mechanism, which needs just the align and QTextFormat (mainly single font).
Mainly it's 2 differents approachs to render the text.