Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QLabel, set text size help
QtWS25 Last Chance

QLabel, set text size help

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 38.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andell
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rahul Das
        wrote on last edited by
        #3

        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.


        Declaration of (Platform) independence.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Andell
          wrote on last edited by
          #4

          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?

          1 Reply Last reply
          0
          • I Offline
            I Offline
            issam
            wrote on last edited by
            #5

            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
            @

            http://www.iissam.com/

            1 Reply Last reply
            1
            • R Offline
              R Offline
              Rahul Das
              wrote on last edited by
              #6

              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.


              Declaration of (Platform) independence.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved