PDA

View Full Version : How to resize label font to fit size



P@u1
18th July 2011, 22:01
Hi everyone,

how can I make a Label which resizes the font size so that the text always fills the whole label?
I tried it by playing with QFontMetrics and it more or less worked, but not rly good.
Is there a good way to do this, or is there maybe already a ready solution for this?

mvuori
18th July 2011, 22:47
Since it is just geometry and mathematics, using QFontMetrics to calculate the new font size will produce accurate results.

srazi
18th July 2011, 23:07
Just a guess ;), try using QFontMetricsF instead of QFontMetrics!