Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.6.0
-
None
-
Tested on Windows with Qt 6.6.0.
Note: on Qt 5.15.11 the workaround is to move "when" property above target value. On Qt 6.6.0 this workaround doesn't work.
Description
This code binds width of yellow rectangle to width of red rectangle if width of red rectangle <=700.
Binding {
id: binding700
target: yellowRect
property: "width"
value: redRect.width
when: redRect.width <= 700
restoreMode: Binding.RestoreNone
}
I would expect that yellow rectangle never exceeds 700 but it does exceed (please check it on the video or launch the attached application).
I guess the reason is that once redRect is changed to 800 first it updates yellowRect with 800, then checks "when" condition and deactivates the binding. Since restoreMode is RestoreNone yellow stays as is which is 800.
This logic affects case with restoreMode: Binding.RestoreValue as well. Because first it updates yellow with 800 and then immedeately restores the value. So we have an unnecessary update (800).
The suggestion is to check "when" condition before updating target value.