Results 1 to 4 of 4

Thread: how to set fontsize for label?

  1. #1
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default how to set fontsize for label?

    hi,
    im using

    lbl->setFont(QFont("Trebuchet",12,QFont::Bold));
    where lbl is QLabel
    for font size and font bold.
    How to set FontSize directly ? (without mentioning fontname as above)
    like lbl.setFontSize

    Thnks
    Bala
    Last edited by BalaQT; 18th September 2009 at 15:17.

  2. #2
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default Re: how to set fontsize for label?

    QFont font = lbl->font ();
    font.setPointSize(12);//set the font size here
    lbl->setFont(font);

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

    BalaQT (18th September 2009)

  4. #3
    Join Date
    Sep 2009
    Posts
    31
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face Re: how to set fontsize for label?

    Hi,
    I don't see any problem in first way with creating font inside method setPointSize() as post BalaQt.
    Maybe problem could be if font "Trebuchet" doesn't exist (then Qt maybe use another font and don't respect set size).
    But if you realy only want to change font size and keep font family, the second way is ok.

    [edit]: sorry .. i don't read first message properly

  5. #4
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: how to set fontsize for label?

    thks babu

    Bala

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.