pmf
pmf

Reputation: 7759

QML: programmatically update binding

Is there a way of programmatically updating (i.e. reevaluating) the current binding of a property (without setting it to something else and resetting it)?

Upvotes: 0

Views: 967

Answers (2)

augre
augre

Reputation: 2051

You can do (hack that should be avoided if possible):

value: foo, bindedValue

or

value: (foo && !foo) || bindedValue

value will be completely reevaluated when calling the following function reevaluateValue():

property bool foo: false

function reevaluateValue() {
    foo = !foo
}

Upvotes: 1

Mitch
Mitch

Reputation: 24416

If your binding looks something like this:

foo: bar

change it to this:

foo: { baz; bar }

where baz is something that changes often enough to cause foo to be re-evaluated when you need it to, which implies that baz would be related. Similar hacks have been done here, for example.

I would recommend fixing the issue properly by not relying on the order of evaluation.

Upvotes: 1

Related Questions