For me even your second example calls onPerimeterChanged only once. It seems that Qt is smart enough to only notify once when it's evalating an expression (that's actually a js function).
Em qua, 1 de abr de 2015 às 19:12, Preet <[email protected]> escreveu: > Hi all > > I want to understand how redundant QML property binding evaluations are > mitigated. Does anyone have a high level idea of how this might be done? > > Consider the following case of properties describing a triangle: > > Item { > property real a: 2; > property real b: 3; > property real c: Math.sqrt(a*a + b*b); > property real perimeter: a+b+c; > > onPerimeterChanged: { console.log("perimeter changed"); } > } > > If you update either 'a' or 'b', onPerimeterChanged will only be called > once. But if you think about the dependencies between the properties, the > perimeter depends on a, b and c: > > change a -> change perimeter > change a -> change c -> change perimeter > > I would have expected two invocations of onPerimeterChanged, but it gets > called only once. The QML engine avoids the redundant change and I'm > curious as to how this is done. > > If you add enough dependencies though, you'll start getting multiple > updates: > > Item { > property real a: 2; > property real b: 3; > property real c: Math.sqrt(a*a + b*b); > property real alt0: a+1; > property real alt1: alt0+1; > property real perimeter: a+b+c+alt1; > > onPerimeterChanged: { console.log("perimeter changed"); } > } > > This will result in onPerimeterChanged being called twice. > > > Preet > _______________________________________________ > Interest mailing list > [email protected] > http://lists.qt-project.org/mailman/listinfo/interest >
_______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
