Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-122383

Check "when" condition before updating target property in Binding

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 6.6.0
    • Quick: Other
    • 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.

    • Windows

    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.

      Attachments

        1. Application.zip
          2 kB
        2. Video.mp4
          871 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            sergeyv Sergey Vetiugov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes