Bindings do not update when a purely JS variable changes, it can only respond to changes in QML properties. You could bind to something like stateObject.value, and still be able to use JS.setValue(stateObject.value + 1) if you wanted. But without going through C++ though you couldn't make stateObject.value read-only to everything but the setValue function.
This is more of a bug than a feature, and support for reevaluating bindings to JS objects is planned for an unknown future release. If you want to force a re-evaluation from C++, you can always expose a C++ property of "forceUpdate", rewrite your expressions to be "forceUpdate + JS.setValue(...);", and emit the notify signal for forceUpdate; -- Alan Alpert On Thu, Jun 13, 2013 at 11:29 AM, Josh Faust <jfa...@suitabletech.com> wrote: > Hey all, > > I have a javascript library, with functions that are used in a lot of > bindings. I'm trying to get those bindings to reevaluate when some variables > used inside the functions change. A simple example: > > // JS.js > .pragma library > var _Value = 0; > function getValue() > { > return _Value; > } > > function setValue(val) > { > _Value = val; > } > > ... > > // in use > Column { > Text { > text: JS.getValue() > } > > Button { > onClicked: JS.setValue(JS.getValue() + 1) > } > } > > When _Value changes, I'd like the QML binding to reevaluate. At the moment > it doesn't look like it will -- and even using JS._Value directly, and > modifying it directly, none of the bindings reevaluate. Is this expected? Is > there any way for me to force reevaluation of these bindings (I'd even be > happy forcing a re-evaluation of all bindings from C++ -- this is for a > development-time feature, so performance is not a concern). > > Thanks > > Josh > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest > _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest