Results 1 to 4 of 4

Thread: QLabel: Resize font to contentsRect

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2016
    Posts
    4
    Thanks
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QLabel: Resize font to contentsRect

    Thanks for your reply.

    I checked the margin and it is configured to zero and also label's margin() returns zero.
    I think it must be somehow connected to StyledPanel as frameShape.

  2. #2
    Join Date
    Jul 2016
    Posts
    4
    Thanks
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QLabel: Resize font to contentsRect

    I finally found the reason for this behavior in the function QLabelPrivate::documentRect in qlabel.cpp:
    Qt Code:
    1. int m = indent;
    2. if (m < 0 && q->frameWidth()) // no indent, but we do have a frame
    3. m = q->fontMetrics().width(QLatin1Char('x')) / 2 - margin;
    To copy to clipboard, switch view to plain text mode 
    When the label's frameShape is set to StyledPanel, frameWidth returns 1.

Similar Threads

  1. how to set custom font to qlabel
    By binary001 in forum Newbie
    Replies: 2
    Last Post: 8th March 2015, 12:40
  2. auto resize font in QSpinBox
    By GoranShekerov in forum Qt Programming
    Replies: 3
    Last Post: 5th March 2015, 12:35
  3. Autoscaling widget font on resize
    By SeanM in forum Qt Programming
    Replies: 0
    Last Post: 10th March 2014, 16:27
  4. How to resize label font to fit size
    By P@u1 in forum Qt Programming
    Replies: 2
    Last Post: 18th July 2011, 23:07
  5. Replies: 1
    Last Post: 2nd August 2008, 15:46

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.