[Development] QProperty and library coding guide

Thiago Macieira thiago.macieira at intel.com
Fri Jul 17 19:36:17 CEST 2020


On Friday, 17 July 2020 09:56:39 PDT Giuseppe D'Angelo via Development wrote:
> Il 17/07/20 17:30, Thiago Macieira ha scritto:
> > I will give a +2 for this patch, since I prefer it. That means adding
> > properties doesn't imply an extra 8 bytes per class in the hierarchy.
> > Imagine a user class hierarcy like QSctpSocket -> QTcpSocket ->
> > QAbstractSocket -> QIODevice -> QObject. If each class has properties,
> > that adds 40 bytes to the full size of QSctpSocket.
> > 
> > [Yes, I know Qt-based classes should just put their properties in the d
> > pointer, but users don't usually have d pointers]
> 
> Even with d pointers, how is that supposed to work? You still need the
> dummy "property object" in the class where it's declared, right? That
> would still add 1 byte to the class, although that can be folded into
> the alignment.
> 
> What am I missing here?

You're not, I was. You're correct, we still need the 1 byte structure added to 
the class.

> So in your example QSctpSocket would still be 24 bytes, because the
> inheritance is not deep enough to make sizeof 32?

Yes, with the IA-64 ABI, assuming we don't mandate [[no_unique_address]] of 
course.

With MSVC, it's 56 bytes.

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





More information about the Development mailing list