How to add custom space to wordwrap in Text



  • 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.


  • Moderators

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



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


Log in to reply
 

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