How do I set line height in QLabel when in WordWrap mode?
Use HTML text:
QString template = "<p style=\"line-height:%1%\">%2<p>";
QString targetText = template.arg(myPercentage).arg(myTex);
QLabel *l = new QLabel(targetText, this);
where myPercentage is like 60 - 80. You will get condensed lines in the WordWrap mode
There is no line spacing property in QLabel
. You can change the widget font, which will change the line's height, but I suspect that is not what you want.
Line height is computed from the QFont
of the widget and can be obtained by the QFontMetrics
associated with the widget. Using this information, you may create your own widget that has a line spacing property (and a text wrap mode), but that represents a lot of low-level work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With