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. Changing the line height of QLabel

Changing the line height of QLabel

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 2.9k Views 3 Watching
  • 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.
  • Dummie1138D Offline
    Dummie1138D Offline
    Dummie1138
    wrote on last edited by
    #1

    Hi. I have the following QLabel, with the following text:

    Sample
    temperature
    

    This is what it looks like on my application:

    a1584353-dbf9-4fbe-b5e8-72e4d71dfc56-image.png

    I am wondering how to make the line height of QLabel smaller. I haven't found any documentation for this, somehow, despite the feature being relatively basic. Please let me know if I missed anything or if more info is required.

    jsulmJ M 2 Replies Last reply
    0
    • Dummie1138D Dummie1138

      @jsulm @mpergand My apologies, I misunderstood. No, I am not using QLayouts or any of it's classes to house my QLabel.

      C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #8

      @Dummie1138 The natural vertical spacing of text automatically wrapped or with deliberate line breaks is given by QFontMetrics::lineSpacing(). This figure is a function of font and size and is not adjustable out-of-the box.

      You can subclass QLabel and provide your own rendering.

      1 Reply Last reply
      0
      • Dummie1138D Dummie1138

        Hi. I have the following QLabel, with the following text:

        Sample
        temperature
        

        This is what it looks like on my application:

        a1584353-dbf9-4fbe-b5e8-72e4d71dfc56-image.png

        I am wondering how to make the line height of QLabel smaller. I haven't found any documentation for this, somehow, despite the feature being relatively basic. Please let me know if I missed anything or if more info is required.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @Dummie1138 What lines do you mean?
        Or do you mean alignment and stretching?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        Dummie1138D 1 Reply Last reply
        0
        • Dummie1138D Dummie1138

          Hi. I have the following QLabel, with the following text:

          Sample
          temperature
          

          This is what it looks like on my application:

          a1584353-dbf9-4fbe-b5e8-72e4d71dfc56-image.png

          I am wondering how to make the line height of QLabel smaller. I haven't found any documentation for this, somehow, despite the feature being relatively basic. Please let me know if I missed anything or if more info is required.

          M Offline
          M Offline
          mpergand
          wrote on last edited by
          #3

          @Dummie1138
          Is your QLabel in a layout ?

          Dummie1138D 1 Reply Last reply
          0
          • jsulmJ jsulm

            @Dummie1138 What lines do you mean?
            Or do you mean alignment and stretching?

            Dummie1138D Offline
            Dummie1138D Offline
            Dummie1138
            wrote on last edited by
            #4

            @jsulm By "line height", I mean this:

            cbf22319-2012-434f-90bb-a9b5d257638e-image.png

            The distance between the top and the bottom.

            1 Reply Last reply
            0
            • M mpergand

              @Dummie1138
              Is your QLabel in a layout ?

              Dummie1138D Offline
              Dummie1138D Offline
              Dummie1138
              wrote on last edited by
              #5

              @mpergand Yes, my QLabel is built in the .ui files.

              jsulmJ 1 Reply Last reply
              0
              • Dummie1138D Dummie1138

                @mpergand Yes, my QLabel is built in the .ui files.

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #6

                @Dummie1138 said in Changing the line height of QLabel:

                my QLabel is built in the .ui files.

                This does not mean that you're using layouts. So the question from @mpergand is still not answered.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                Dummie1138D 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @Dummie1138 said in Changing the line height of QLabel:

                  my QLabel is built in the .ui files.

                  This does not mean that you're using layouts. So the question from @mpergand is still not answered.

                  Dummie1138D Offline
                  Dummie1138D Offline
                  Dummie1138
                  wrote on last edited by
                  #7

                  @jsulm @mpergand My apologies, I misunderstood. No, I am not using QLayouts or any of it's classes to house my QLabel.

                  C 1 Reply Last reply
                  0
                  • Dummie1138D Dummie1138

                    @jsulm @mpergand My apologies, I misunderstood. No, I am not using QLayouts or any of it's classes to house my QLabel.

                    C Offline
                    C Offline
                    ChrisW67
                    wrote on last edited by
                    #8

                    @Dummie1138 The natural vertical spacing of text automatically wrapped or with deliberate line breaks is given by QFontMetrics::lineSpacing(). This figure is a function of font and size and is not adjustable out-of-the box.

                    You can subclass QLabel and provide your own rendering.

                    1 Reply Last reply
                    0
                    • Dummie1138D Dummie1138 has marked this topic as solved on

                    • Login

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