【发布时间】:2019-04-23 15:23:09
【问题描述】:
我有一个 TextInput QML (Qt 5.12.2) 控件,它包含在一个 Rectangle 项(用于样式)中,我用字符串预先填充了该控件。有时该字符串可能比 TextInput 的最大宽度长。发生这种情况时,文本输入中的文本会显示字符串的结尾,如下所示:
但是,我希望 TextInput 中的文本从字符串的开头显示,如下所示:
这是一个重现此的示例:
import QtQuick 2.12
import QtQuick.Window 2.12
Window {
visible: true
width: 640
height: 480
Rectangle {
border.width: 1
border.color: 'black'
height: childrenRect.height
width: 600
clip: true
TextInput {
width: parent.width
text: "1. The quick bown dog jumps over the lazy dog. 2. The quick bown dog jumps over the lazy dog. 3. The quick bown dog jumps over the lazy dog. 4. The quick bown dog jumps over the lazy dog."
}
}
}
我尝试将autoScroll 设置为 false,这确实使它以我想要的方式显示,但也禁用了用户滚动文本的能力,如果他们想阅读文本的结尾。我还有什么办法可以解决这个问题吗?
【问题讨论】: