Upgrade binding loop workaround to real solution.

This commit is contained in:
Julien Wadel 2022-07-07 15:28:51 +02:00
parent 4d139b2991
commit 0b8e72710c
3 changed files with 7 additions and 16 deletions

View file

@ -55,7 +55,7 @@ Rectangle {
ScrollBar.vertical: ForceScrollBar {
id: scrollBar
//policy: flickable.contentHeight > height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff // Do not use because of binding loop issues
contentSizeTarget: flickable.contentHeight
sizeTarget: flickable.height
Component.onCompleted: updatePolicy()

View file

@ -12,22 +12,18 @@ ScrollBar {
property int contentSizeTarget
property int sizeTarget
onContentSizeTargetChanged: delayUpdatePolicy.restart()
onSizeTargetChanged: delayUpdatePolicy.restart()
onContentSizeTargetChanged: Qt.callLater( scrollBar.updatePolicy)
onSizeTargetChanged: Qt.callLater( scrollBar.updatePolicy)
policy: ScrollBar.AlwaysOff
function updatePolicy(){
policy = contentSizeTarget > sizeTarget ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
}
function delayPolicy(){
delayUpdatePolicy.restart()
Qt.callLater( scrollBar.updatePolicy)
}
Component.onCompleted: updatePolicy()
Timer{// Delay to avoid binding loops
id:delayUpdatePolicy
interval:10
onTriggered: scrollBar.updatePolicy()
}
background: Rectangle {
anchors.fill: parent

View file

@ -133,13 +133,8 @@ Item {
model: ContentProxyModel{
chatMessageModel: mainItem.chatMessageModel
}
Timer{// Delay to avoid binding loops
id:delayUpdate
interval:10
onTriggered: replyMessage.height = replyMessage.contentHeight
}
onContentHeightChanged: delayUpdate.restart()
//height: contentHeight
onContentHeightChanged: Qt.callLater( function(){replyMessage.height = replyMessage.contentHeight})
delegate: ChatContent{
contentModel: $modelData