Results 1 to 2 of 2

Thread: How to change font size in QLabel(QLabel created from Qdesigner)

  1. #1
    Join Date
    Jun 2006
    Location
    San Diego, USA
    Posts
    95
    Thanks
    9
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default How to change font size in QLabel(QLabel created from Qdesigner)

    Hi All,

    How to change font size for a QLabel? Qlabel was created fron QDesigner.
    Before querying to you all I tried changing code as explained in previous posts.
    http://www.qtcentre.org/forum/f-qt-p...size-5508.html
    http://www.qtcentre.org/forum/f-qt-p...view-8597.html

    snippet of code:
    Method 1:
    Qt Code:
    1. label1->setText("Qt Label1");
    2. //set font
    3. QFont font = label1->font();
    4. font.setPointSize(72);
    5. font.setBold(true);
    6. label1->setFont(font);
    To copy to clipboard, switch view to plain text mode 
    Method 2:
    Qt Code:
    1. QString ritchText("<html><head><meta name=\"qrichtext\" content=\"1\" /></head>"
    2. "<body style=\" white-space: pre-wrap; font-family:Sans Serif; "
    3. "font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;\">"
    4. "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; "
    5. "margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:70pt;\">
    6. Qt Label1 </p>" "</body></html>");
    7. label1->setText(ritchText);
    To copy to clipboard, switch view to plain text mode 
    Even after the changes applied from above posts, it not increasing the font size for a QLabel.

    The only difference I can see is my QLabel was created from QDesigner and in the posts it was created manually. Is this(creating qlabel from designer) causing me difficulty in changing the font size for a qlabel? Please help.

    Thanks & Regards,
    Arun.
    Last edited by jpn; 1st August 2008 at 23:51. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2008
    Posts
    31
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to change font size in QLabel(QLabel created from Qdesigner)

    Arun,

    I've used the following code with a QDesigner created QLabel with no problems:

    Qt Code:
    1. QFont f( "Arial", 10, QFont::Bold);
    2. textLabel->setFont( f);
    To copy to clipboard, switch view to plain text mode 

    Regards,

    Don

  3. The following user says thank you to GTBuilder for this useful post:

    8Observer8 (2nd December 2020)

Similar Threads

  1. Font size calculation when painting in a QImage
    By Ishark in forum Qt Programming
    Replies: 3
    Last Post: 15th July 2007, 23:22
  2. change font size and button size of QMessageBox
    By nass in forum Qt Programming
    Replies: 6
    Last Post: 13th September 2006, 20:16

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.