[Development] New property system

Lars Knoll lars.knoll at qt.io
Tue Sep 1 11:54:49 CEST 2020

> On 31 Aug 2020, at 06:17, Thiago Macieira <thiago.macieira at intel.com> wrote:
> On Wednesday, 26 August 2020 00:18:49 PDT Lars Knoll wrote:
>> To summarise the advantages of the redesigned system:
>> * Very little memory overhead if bindings aren’t used
>> * Very low runtime overhead if bindings aren’t used
>> * Binding support can be added to properties in QObjects in a binary
>> compatible way * Straight forward extension of the existing and known
>> property system * Much easier to port existing properties
>> https://codereview.qt-project.org/c/qt/qtbase/+/310748 is also the end of
>> the patch series that does implement the required infrastructure. It’s
>> still lacking a bit of documentation, but the series is now pretty clean
>> and should be in a good state for reviewing.
> Hello Lars
> Thank you for the work. I appreciate removing the dependency on 
> [[no_unique_address]], which we're still not completely sure the implications 
> of, for now. By the way, this re-allows GCC 7 and 8 in the for Qt 6.

Thanks. I think we’ll leave it with gcc 8 as the minimum version.
> But I'm still confused as to what the API should be. In your submission above, 
> we see:
>     int currentTime() const;
> +    QBindable<int> bindableCurrentTime();
>     int currentLoopTime() const;
> Is this what the API is expected to be for new APIs? Or is it only for 
> compatibility?

Both. API wise, this is all that’s required to make properties bindable now. So you can easily change an existing property and make it bindable by implementing one additional method (and changing the how the property data is being stored).

> If it's only for compatibility, what should one write in the Q_PROPERTY header 
> for new properties?

As said, it’s for both old and new properties in QObjects. What you need to do to convert a property and make it bindable is to add the one method, and add a “BINDABLE bindableFoo” section in the Q_PROPERTY macro. The second part is only required so that QMetaProperty also knows about the bindability. Setting up a binding from C++ does only require the bindableFoo() accessor.


More information about the Development mailing list