读书人

QML TextInput有关问题

发布时间: 2012-08-29 08:40:14 作者: rapoo

QML TextInput问题
如何使得输入的内容不超出TextInput的大小

正常的是如果输入的文字长度大于输入框长度,文字隐藏开头部分使得后面的文字显示
但现在的情况是但输入文字大于输入框时候,文字将全显示,及文字显示将超出输入框。
我设置了Clip属性,不过没有效果,如何处理?

[解决办法]
Rectangle {
id: test
width: 300
height: 100
Rectangle
{
height: 30
width:100
anchors.centerIn: parent
color:"lightblue"
clip: true
TextInput
{
id:searchInput
width: 100

anchors.verticalCenter: parent.verticalCenter
font.pixelSize:18
color:"black"
}
}
}
我这样写可以达到你想要的效果
另外 你描述的正常情况和这个属性有关:

autoScroll : bool

Whether the TextInput should scroll when the text is longer than the width. By default this is set to true.

读书人网 >QT开发

热点推荐