Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to add custom space to wordwrap in Text
Forum Update on Monday, May 27th 2025

How to add custom space to wordwrap in Text

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 949 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.
  • L Offline
    L Offline
    LostQMLer
    wrote on last edited by
    #1

    Hello All,

    Does anyone know how can I give pixel space between two lines when Qt is performing the wordwrap for the sentence?

    Below is the code reference:-

    Rectangle {
                id:LabelTxtWdgt
                x: 221
                y: 76
                width: 328
                height: 328
                color: "transparent"
                border.color: "green"
    
                Rectangle {
                    id: label1
                    width : 270
                    height : 33
                    color: "transparent"
                    border.color: "yellow"
                    anchors
                    {
                        top:LabelTxtWdgt.top
                        topMargin: 28
                        left: LabelTxtWdgt.left
                        leftMargin: 29
                    }
    
                    Text {
                        text: "Welcome to the world of QT "
                        elide: Text.ElideNone
                        font.pointSize: 24
                        color: "red"
                        width: 270
                        height: 33
                        wrapMode: Text.WrapAnywhere
                        horizontalAlignment: Text.AlignLeft
                    }
                }
    
                Rectangle {
                    id: text1
                    width : 270
                    height : 33
                    color: "transparent"
                    border.color: "white"
                    anchors
                    {
                        top: LabelTxtWdgt.top
                        topMargin: 59
                        left: LabelTxtWdgt.left
                        leftMargin: 29
                    }
                }
            }
    

    The output for the above code is as follow.
    0_1517912202453_ea665907-3902-4cc7-9d1b-089b1647e238-image.png

    I want the second line should start from the blue line as shown in the above image. Any help is welcome. Thanks in advance.

    raven-worxR 1 Reply Last reply
    0
    • L LostQMLer

      Hello All,

      Does anyone know how can I give pixel space between two lines when Qt is performing the wordwrap for the sentence?

      Below is the code reference:-

      Rectangle {
                  id:LabelTxtWdgt
                  x: 221
                  y: 76
                  width: 328
                  height: 328
                  color: "transparent"
                  border.color: "green"
      
                  Rectangle {
                      id: label1
                      width : 270
                      height : 33
                      color: "transparent"
                      border.color: "yellow"
                      anchors
                      {
                          top:LabelTxtWdgt.top
                          topMargin: 28
                          left: LabelTxtWdgt.left
                          leftMargin: 29
                      }
      
                      Text {
                          text: "Welcome to the world of QT "
                          elide: Text.ElideNone
                          font.pointSize: 24
                          color: "red"
                          width: 270
                          height: 33
                          wrapMode: Text.WrapAnywhere
                          horizontalAlignment: Text.AlignLeft
                      }
                  }
      
                  Rectangle {
                      id: text1
                      width : 270
                      height : 33
                      color: "transparent"
                      border.color: "white"
                      anchors
                      {
                          top: LabelTxtWdgt.top
                          topMargin: 59
                          left: LabelTxtWdgt.left
                          leftMargin: 29
                      }
                  }
              }
      

      The output for the above code is as follow.
      0_1517912202453_ea665907-3902-4cc7-9d1b-089b1647e238-image.png

      I want the second line should start from the blue line as shown in the above image. Any help is welcome. Thanks in advance.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @LostQMLer
      if i understood you correct then take a look at the lineHeight property of the Text element.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      L 1 Reply Last reply
      2
      • raven-worxR raven-worx

        @LostQMLer
        if i understood you correct then take a look at the lineHeight property of the Text element.

        L Offline
        L Offline
        LostQMLer
        wrote on last edited by
        #3

        @raven-worx
        Thanks for pointing the property. It helped me to achieve the POC I wanted.

        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