当前位置: 代码迷 >> QT开发 >> QML TextInput有关问题
  详细解决方案

QML TextInput有关问题

热度:44   发布时间:2016-04-25 04:37:16.0
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.