QML TextEdit 单行裁剪实现方法
可以通过设置 TextEdit 的属性 'wrapMode' 为 TextEdit.NoWrap 来实现单行裁剪,示例代码如下:
import QtQuick 2.0
import QtQuick.Controls 2.0
ApplicationWindow {
width: 400
height: 300
visible: true
TextEdit {
id: myTextEdit
x: 50
y: 50
width: 200
height: 30
wrapMode: TextEdit.NoWrap // 设置为单行裁剪
text: 'This is a long text that should be clipped to a single line.'
}
}
原文地址: https://www.cveoy.top/t/topic/nRmb 著作权归作者所有。请勿转载和采集!