[Development] QProperty and library coding guide

Thiago Macieira thiago.macieira at intel.com
Thu Jul 16 17:19:21 CEST 2020


On Thursday, 16 July 2020 03:43:58 PDT Volker Hilsheimer wrote:
> The various macros involved provide this. Each property is represented by an
> instance of a struct with no data members, but just methods that forward
> calls to the accessor, which in Qt is typically the d-pointer (where the
> QProperty itself lives as well).

That's why I asked about 59*sizeof(void*) addition to QWidgetPrivate.
 
> For pre-C++20 (where it’s possible to have zero-size structs), and for
> compilers that don’t respect the [[no_unqiue_address]] attribute, all these
> struct-instances are put into a union. In that case, a class using
> QProperty will be larger (by the same amount no matter the number of
> properties) than the same class in Qt 5. With C+++ 20 and compilers that do
> respect [[no_unique_address]], the size and layout of these classes will be
> the same.

Hmm... design question then: if the address isn't relevant and the data inside 
isn't relevant either (because it can't be), why do we need a member in the 
first place? What information does it convey that is neither the address nor 
the contents?

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products





More information about the Development mailing list