[Development] Property bindings in Qt 6
Matthew Woehlke
mwoehlke.floss at gmail.com
Mon Sep 30 18:10:52 CEST 2019
On 26/09/2019 11.02, Simon Hausmann wrote:
> I would like to propose an API that replaces the setter and getter
> functions on objects with a new property template class that
> encapsulates the property value instead, and the ability to tie
> binding expressions to these properties for automatic updates. In
> short, it looks like this:
>
> QProperty<QString> surname("John");
> QProperty<QString> lastname("Smith");
>
> QProperty<QString> fullname;
> fullname.setBinding([&]() { return surname() + " " + lastname(); });
I suppose this is convenient, but it also means creating a new function
object for *every instance of the type*. A more "traditional" approach
would only have *one* member function (that is called with the implicit
'this' parameter).
Have you at least considered doing something similar here, i.e. instead
of using a capturing lambda, instead use a stateless function that takes
the owning class as a parameter?
--
Matthew
More information about the Development
mailing list