[Development] HEADS UP: Don't use QList, use Q_DECLARE_TYPEINFO

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Fri Jul 10 11:12:16 CEST 2015


Il 10/07/2015 11:05, Curtis Mitch ha scritto:
> So QQuickItem, for example, should have Q_DECLARE_TYPEINFO?

No, because you can't put a QQuickItem in a container, since you can't 
copy it. You can create a container of pointers to QQuickItems, but 
pointers are automatically OK:

http://code.woboq.org/qt5/qtbase/src/corelib/global/qtypeinfo.h.html#79

> And please, whenever you add a new type (not just class, *any* type, incl.
> enums, but excluding QFlags (which are automatically primitive)),

^ and pointers.

> What happens if you don't use the macro for a type? Do containers assume the worst about that type (that it's complex, etc.)?

Yes, complex is the default. For QList, that means that every single 
object it contains will be allocated on the heap with new.

HTH,
-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Software Engineer
KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
KDAB - The Qt Experts

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


More information about the Development mailing list