QLabel, set text size help



  • Hi, I want to set text size in my QLabel. But here is the problem. When i use setPointSize, size 9 is too small and size 10 is too big. Same problem with setPixelSize. Do you have any other idea, how set point size to 9,5 or similar?



  • Use a font that supports such fractional sizes and/or has the size you want. Fonts usually can't be resized to all thinkable sizes as they would look very blurred.



  • You can use the style sheet as well, conveniently from the designer , or programmatically.

    For example,
    @label->setStyleSheet("font: 18pt;");@

    EDIT :
    Did not try with 9.5. Can't notice ,if there is any difference.



  • DerManu: Thanks for tip, do you know any font, that can fit ? I havent found it yet.

    Rahul Das: I tried this too, but there is no difference between 9,5 and 10.

    Any other idea? Exist some function, that can take the label like picture or something, and resize it like 90% or 110% from original size?



  • Hi Andell,
    try to use HTML tags. Examples :
    @
    QLabel("<span style="font-size:9.5em; ">kdkdk hhyy</span>");
    @
    or
    @
    QLabel("<span style="font-size:9.5ex; ">gdgdg</span>");
    @
    or
    @
    QLabel("<span style="font-size:5%; ">ldldl</span>");
    @
    or
    @
    QLabel("<span style="font-size:small; ">ldldl</span>");
    // and use : xx-small , x-small, small, medium, large, x-large, xx-large
    @



  • Yes, you can use [[doc:QFont]]
    @
    QFont::pointSizeF ()@

    function as well.

    bq. Rahul Das: I tried this too, but there is no difference between 9,5 and 10.

    Try with bigger font size,like 29.5 and 30. You can make out the difference.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.