# How to vertical the text and control the line spacing by QPainter::drawText(rect,text）

• I have tried to add '\n' to each character, but I find line spacing is too large， how I can control this line spacing.
painter->drawText (position,"Qt by \n Trolltech");

thanks

• You can try to modify the different parameters of a QFont.

@
MyWidget::paintEvent(...)
{
QPainter p(this);
QFont ft = font();
ft.xxx();
p.setFont(ft);
}
@

But I'm not 100% sure, whether you can change line height...

• thanks Gerolf.
the font size is 16, it can be changed by user. it means that the text size is ok, just the line spacing is too large，because of "\n". but how to reset line spacing.

• I meant the line height of the font, which is typically ascent + descent + leading (look at QFontMetrics) and which is located in the font properties.

• ok, I see.

• I am sorry, I still don’t find that which function can set line spacing in QFont. can someone help me .

• [quote author="dxwang" date="1312182018"]I am sorry, I still don’t find that which function can set line spacing in QFont. can someone help me .[/quote]

Did you find the answer. I am searching something similar ?

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