# How to get font height from QTextEdit where text is multiline?

• Hello,

``````    QTextEdit text("test");

QFontMetrics fm(text.font());

QString myText = text.toPlainText();

int calcHeight = fm.height();
``````

When I use the code above I get width and height of text "test". But what if the text will be like "test\ntest2\ntest3"?
Using:

``````int calcHeight = fm.height();
``````

I get the same value.

So can I get the multiline height?

• Hi
You have to tell it to wordWrap and give it an area
like
fm.boundingRect(QRect(0,0,width,100), Qt::TextWordWrap, text);
Then you should be able to use newlines.