您可以使用wrapMode属性将TextEdit的文本换行方式更改为TextEdit.NoWrap,然后使用clip属性将其超出宽度的文本裁剪掉。

例如:

TextEdit {
    wrapMode: TextEdit.NoWrap
    clip: true
    width: 200 // 设置TextEdit的宽度
    text: "This is a long text that will be clipped if it exceeds the width of the TextEdit."
}

这将导致TextEdit的文本超过宽度时被裁剪掉而不是自动换行。

QML中TextEdit超过宽度裁剪而不是换行

原文地址: https://www.cveoy.top/t/topic/epxm 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录