Qml text wrap (max width)

后端 未结 7 1786
抹茶落季
抹茶落季 2021-02-19 02:56

I would like to put text inside a bubble, and I want that my bubble be equal to the text width, but if the text length is too long, I would like the text to wrap automatically a

7条回答
  •  臣服心动
    2021-02-19 03:38

    Try this:

    Text {
        property int MAX_WIDTH: 400
        width: MAX_WIDTH
        onTextChanged: width = Math.min(MAX_WIDTH, paintedWidth)
    }
    

提交回复
热议问题