user5585984
user5585984

Reputation:

Dynamic text size QLabel

What is the best way to determine if text-size exceeds width of QLabel? And according to that, change the text-size?

I have a QLabel with word-wrap option set to true, but when text is so long it is being cropped from left and right side.

Upvotes: 1

Views: 2524

Answers (1)

vahancho
vahancho

Reputation: 21220

You might want to try this approach:

QLabel label;
QRect r = label.fontMetrics().boundingRect( "My text" ) );
int textWidth = r.width();

Upvotes: 2

Related Questions