Is your label widget managed by a layout? If so, you should set the sizeConstraint on the topmost layout (label->widnow()->layout()), so that the window will be always sufficiently large to hold all of the contents.
– Kuba hasn't forgotten Monica
1 Answers
2
votes
You might want to try this approach:
QLabel label;
QRect r = label.fontMetrics().boundingRect( "My text" ) );
int textWidth = r.width();
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more
sizeConstraint
on the topmost layout (label->widnow()->layout()
), so that the window will be always sufficiently large to hold all of the contents. – Kuba hasn't forgotten Monica