qml Text控件专门用于显示非编辑文本,功能还是比较强大的。改变多行文本,需要修改wrapMode: Text.WrapAnywhere,elide: Text.ElideRight,maximumLineCount:2即可
1 import QtQuick 2.9 2 import QtQuick.Window 2.2 3 4 Window { 5 visible: true 6 width: 640 7 height: 480 8 title: qsTr("Hello World") 9 Text{ 10 id:text_test 11 12 width: 200 13 14 anchors.horizontalCenter: parent.horizontalCenter 15 16 clip :true //是否剪切掉超出显示范围的文字,默认false 17 18 text:"Hello Wo111111111111111111111" //需要显示的文字 19 20 color: "red" //文字颜色 21 22 font.family: "Corbel"