[Development] Making Q_OBJECT_COMPAT_PROPERTY public

Arno Rehn a.rehn at menlosystems.com
Tue Jun 11 09:16:48 CEST 2024


Hi Fabian,

Am 10.06.2024 um 16:37 schrieb Fabian Kosmale:
> there has been no further development on making
> QObjectBindableProperty public, or much work at all when it comes to
> extending bindable properties and their usage inside Qt. The most
> substantial feature was an external contribution to support QBindable
> from non-QProperty based properties, as long as they have a change
> signal (https://doc.qt.io/qt-6/qbindable.html#QBindable-3).

Yep, we're also using this in a few places already. But it's a little
more cumbersome to use. I also assume it's slower, not least because of
the string-based lookup on construction.

> The main reason why QObjectBindableProperty was never made public is
> that it is rather easy to shoot oneself in the foot with it, as we
> discovered in quite a few places inside Qt itself.

I've found the issues on Jira [0]. From what I gather the API and usage 
patterns have changed a little bit over time. By now the pattern
seems to be stable and pretty much identical to "old-style" property 
setters:

     // From QTimeLine:
     d->duration.removeBindingUnlessInWrapper();
     if (duration != d->duration.valueBypassingBindings()) {
         d->duration.setValueBypassingBindings(duration);
         d->duration.notify();
     }

Looks pretty much like the typical property setter with the addition of 
a call to removeBindingUnlessInWrapper().

Are there actually any footguns left?

[0] 
https://bugreports.qt.io/browse/QTBUG-89890?jql=text%20~%20%22Q_OBJECT_COMPAT__PROPERTY%22

> I think it might be a good idea to have a discussion at Contributor
> summit where we can talk about the past, present and future of
> QProperty. I've added it to this year's s program proposal (at 
> https://wiki.qt.io/Qt_Contributor_Summit_2024_-_Program)

Thanks! Would love to discuss this in person, but I won't be able to 
make it to QtCS this year :-(

-- Arno

> Von: Development
> <development-bounces at qt-project.org> im Auftrag von Arno Rehn
> <a.rehn at menlosystems.com> Gesendet: Montag, 10. Juni 2024 12:48 An:
> Qt development mailing list Betreff: [Development] Making
> Q_OBJECT_COMPAT_PROPERTY public
> 
> Hey everyone,
> 
> in our codebase, we have a lot of property setters with
> side-effects. We'd still like to introduce bindable properties -
> they're awesome!
> 
> However, QObjectBindableProperty/QProperty require trivial setters,
> so that doesn't work for us. Qt uses Q_OBJECT_COMPAT_PROPERTY
> internally for setters-with-side-effects, but that is private API as
> of now.
> 
> I've found notes from Qt CS 2021 indicating that this could be made 
> public in the future [0]. Has there been any development in this 
> direction? If not, is there anything that's blocking this?
> 
> Regards, Arno
> 
> [0]: https://wiki.qt.io/QtCS2021_-_Qt_Property_Bindings
> 
> -- Arno Rehn Principal Software Engineer Tel +49 89 189 166 0 Fax +49
> 89 189 166 111 a.rehn at menlosystems.com www.menlosystems.com
> 
> Menlo Systems GmbH Bunsenstrasse 5, D-82152 Martinsried, Germany 
> Amtsgericht München HRB 138145 Geschäftsführung: Dr. Michael Mei, Dr.
> Ronald Holzwarth USt.-IdNr. DE217772017, St.-Nr. 14316170324
> 
> -- Development mailing list Development at qt-project.org 
> https://lists.qt-project.org/listinfo/development

-- 
Arno Rehn
Principal Software Engineer
Tel +49 89 189 166 0
Fax +49 89 189 166 111
a.rehn at menlosystems.com
www.menlosystems.com

Menlo Systems GmbH
Bunsenstrasse 5, D-82152 Martinsried, Germany
Amtsgericht München HRB 138145
Geschäftsführung: Dr. Michael Mei, Dr. Ronald Holzwarth
USt.-IdNr. DE217772017, St.-Nr. 14316170324



More information about the Development mailing list