【发布时间】:2016-06-06 20:08:28
【问题描述】:
我在它下面有一个列表视图和一个文本区域。我希望列表视图的高度相对于文本区域的大小增加或减少。我尝试将 listview 的底部锚定到 textarea 的顶部,但没有成功。然后我尝试将 textarea 的顶部锚定到 listview 的底部,也没有用。两个都试过了,都不行。每次它给出为属性“height”检测到的绑定循环的运行时错误/警告 我也在 textarea 的范围内尝试过这个,但是我有相同的运行时错误/警告并且没有结果:
onTextChanged: {
listView.anchors.bottomMargin = height;
}
我怎样才能做到这一点?
代码如下:
ListView{
id: listView
// anchors.fill: parent
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
anchors.margins: 10
delegate: ChatMessageItem{}
model: listModel
spacing: 15
}
Rectangle{
id: rectInput
height: childrenRect.height + 6
width: parent.width
// anchors.top: listView.bottom
anchors.bottom: parent.bottom
color: "#BDC3C7"
TextArea{
id: tMsg
placeholderText: qsTr("Enter message")
width: parent.width - 30
anchors.bottom: parent.bottom
anchors.bottomMargin: 2
anchors.left: parent.left
anchors.leftMargin: 1
focus: true
wrapMode: TextArea.Wrap
background: Rectangle {
border.color: "#BDC3C7"
border.width: 2
color: "#ECF0F1"
}
onTextChanged: {
listView.anchors.bottomMargin = height;
}
}
}
【问题讨论】:
-
您不应该删除您的答案。它对我有用。问题是我的列表视图没有滚动到底部,这让我觉得它不起作用。我修好了。我仍然得到绑定循环错误。 @coyotte508
-
@coyotte508 也许我可以再次看到您的答案以查看绑定循环问题并接受它。