[Development] QProperty and library coding guide

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Sat Jul 18 22:36:11 CEST 2020


Il 18/07/20 12:08, Arno Rehn ha scritto:
> Can't we just hide the QProperty behind a method call, like with an
> ordinary getter method? E.g.
> 
> class Foo
> {
>      // ...
>      QPropert<int> &bar() {
>          Q_D(Foo);
>          return d->bar;
>      }
> };
> 
> struct FooPrivate {
>      QProperty<int> bar;
> };
> 
> Sure, property access then isn't as nice as with the struct wrapper,
> because you have the method call in between, but at least it's not
> undefined behavior and there's a lot less complexity when putting it
> into the pimpl object.

I'm assuming that one of the goals is to make the new property syntax 
invisible and identical for the users. Code like this

   auto value = obj->property();

must still compile, and decltype(value) better be the actual property 
type and not any proxy object (which are still second class citizens in 
C++).

My 2 c,
-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4329 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20200718/64d80309/attachment-0001.bin>


More information about the Development mailing list