Find out labelSize after wordWrap
i have a problem with drawText, wordWrap and QLabel
I create a QLabel and set a very long text. Then i draw the labelText.
QLabel *label = new QLabel
label->setText("a very long text thats not fit in the label width")
paint->drawText(QRect(10,10,50,16), Qt::alignVCenter | Qt::textWordWrap, label->text());
How I can find out the new label height after the WordWrap? I Have to set a new height that the text fit in the QRect.
If you call QLabel::setWordWrap(true) and then set the text then the label will adjust itself (within the constraints of its parent and layout).
If you must paint your widget yourself then use the version of drawText() that takes a pointer to QRectF in which to return the bounding rect of the text.