> On 1 Sep 2020, at 16:12, Thiago Macieira <[email protected]> wrote:
> 
> On Tuesday, 1 September 2020 02:54:49 PDT Lars Knoll wrote:
>>> 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.
> 
> Sorry, I wasn't very clear.
> 
> For new properties and especially in new classes, is there a preferred syntax 
> that doesn't have to keep compatibility?

We keep our naming for setters and getters as in Qt 5:

For a property “foo”, the getter is called “foo” unless the property is boolean 
in which case we use “isFoo”. The setter is called “setFoo”. 

The new API is the getter for the interface that allows to add bindings to 
properties and introspect them. So far my naming proposal for that one is to 
call it “bindableFoo” and it returns a QBindable<PropertyType>. I’m open to 
other suggestions for the naming, but this is the best we could come up with 
when I discussed with Ulf and Fabian.

In user code and/or classes that are not derived from QObject, you can use 
QProperty<T> directly. Then you can call setBinding() directly on the property 
and do not need the bindableFoo() API (but loose the introspection through 
QMetaProperty in that case).

Does that answer your question?

Cheers,
Lars

_______________________________________________
Development mailing list
[email protected]
https://lists.qt-project.org/listinfo/development

Reply via email to