Reputation: 903
When you bind a property it will be reevaluated if one of the proprieties to which is bounded is changed. Example:
property bool test: prCond1 || prCond2 || ... || prCondN
When a condition is changed test
is reevaluated.
Now... I want something similar but for triggering a javascript function:
when one of several conditions prCond1 || prCond2 || ... || prCondN
is changed I want a function to be called.
If there was only one condition I could write:
onPrCond1Changed: {
functionCall()
}
But when you take into account more than one condition what is the best way to do it? Is there a standard way?
Basically I need something like this:
functionCall() if one of these changes: prCond1 || prCond2 || ... || prCondN
Where prCond's may be of different types.
Upvotes: 0
Views: 71
Reputation: 721
A possible solution would be to group the variables into a variant list and look for changes on the list.
property var myObject = {'prop': 'value'}
property variant conditions = [prCond1, prCond2, myObj]
onConditionsChanged: {
console.log("one of the conditions have changed");
}
Note that changes in the properties of myObj will not trigger the changeEvent, unless the object itself is changed (e.g. myObj = new Object({'prop': 'newValue'}) )
Upvotes: 1