Results 1 to 3 of 3

Thread: How to resize label font to fit size

  1. #1
    Join Date
    Jun 2011
    Posts
    38
    Thanks
    8
    Thanked 1 Time in 1 Post

    Default How to resize label font to fit size

    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?

  2. #2
    Join Date
    May 2011
    Posts
    240
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: How to resize label font to fit size

    Since it is just geometry and mathematics, using QFontMetrics to calculate the new font size will produce accurate results.

  3. #3
    Join Date
    Jul 2010
    Posts
    41
    Thanks
    6
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to resize label font to fit size

    Just a guess , try using QFontMetricsF instead of QFontMetrics!

Similar Threads

  1. Font Height and width based on font size
    By Ghufran in forum Qt Programming
    Replies: 1
    Last Post: 31st July 2010, 08:02
  2. changing QLabel font size(label created on the graphicsView)
    By maverick_pol in forum Qt Programming
    Replies: 11
    Last Post: 17th August 2007, 08:36
  3. Replies: 1
    Last Post: 24th October 2006, 16:40
  4. change font size and button size of QMessageBox
    By nass in forum Qt Programming
    Replies: 6
    Last Post: 13th September 2006, 19:16
  5. Change Font Color of Label and CheckBox
    By mahe2310 in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 15th June 2006, 10:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.