Qt – QLabel auto multiple lines

qlabelqt

For example, we have a QLabel with MaximumWidth set to 400.
When we try to display some text with pixel width more than 400, it's shown cut off.
Is there any way to make QLabel display this string in multiple lines without using QFontMetrics or the like?

Best Answer

If I understood your question correctly, you should use the setWordWrap function for your label, with true as its parameter.

QLabel lbl("long long string");
lbl.setWordWrap(true);
Related Topic