On 26.09.19 20:50, Ville Voutilainen wrote:
On Thu, 26 Sep 2019 at 21:08, Pierre-Yves Siret <py.si...@gmail.com> wrote:
I feel like custom getters and the ability to mark a property dirty are needed
too.
You might have a property that's provided by an outside system, and you maybe
don't want to query it every time it changes, only when there's an observer
bound to that property.
About the
QProperty<QString> fullname;
fullname.setBinding([&]() { return surname() + " " + lastname(); });
Does it store a QString internally and modify it whenever surname & lastname
changes thus taking some space in memory or is it just evaluated lazily and never
stored?
Based on my reading of the code, it does store a QString, but it will
modify it only if you get the property's value at least once. Also,
based on my reading, subsequent
modifications happen only if the dependent properties are changed,
since it bookkeeps dependency tracking information via thread-local
binding state,
which is the magic bit that makes lazy evaluation of the dependencies
tick. The lambda passed to setBinding looks like it's executing
arbitrary code that has no statements
of dependencies, but due to the thread_local state, the dependencies
are tracked automatically.
Right, Simon?
That's right.
As for the getter/setter, in addition to what Thiago suggests, we could also
add template parameters with customization points.
_______________________________________________
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development