[Development] QProperty and library coding guide
Arno Rehn
a.rehn at menlosystems.com
Sat Jul 18 12:08:22 CEST 2020
On 17/07/2020 19:30, Ulf Hermann wrote:
>> I am confused. Removing the struct means we’re back to a
>> setFoo()/foo() style API, and especially, we have a different API for
>> people using Property directly and what we provide in our public API.
>> That simply doesn’t make sense.
>
> I was assuming we'd also add setBindingOnFoo() etc. Yes, that would be
> different API than what we provide for QProperty directly. If we can
> avoid it, we should.
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.
Regards,
Arno
--
Arno Rehn
Tel +49 89 189 166 0
Fax +49 89 189 166 111
a.rehn at menlosystems.com
www.menlosystems.com
Menlo Systems GmbH
Am Klopferspitz 19a, 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