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

Curtis Mitch mitch.curtis at theqtcompany.com
Fri Jul 10 11:05:24 CEST 2015


> -----Original Message-----
> From: development-bounces+mitch.curtis=theqtcompany.com at qt-project.org
> [mailto:development-bounces+mitch.curtis=theqtcompany.com at qt-
> project.org] On Behalf Of Marc Mutz
> Sent: Friday, 10 July 2015 11:04 AM
> To: development at qt-project.org
> Subject: [Development] HEADS UP: Don't use QList, use Q_DECLARE_TYPEINFO
> 
[snip]
> 
> And please, whenever you add a new type (not just class, *any* type,
> incl.
> enums, but excluding QFlags (which are automatically primitive)),
> strongly
> consider Q_DECLARE_METATYPE with the appropriate flag (yes, even
> Q_COMPLEX_TYPE). About the only time this can be considered optional is
> for
> polymorphic classes. It should become second nature to
> Q_DECLARE_TYPEINFO.
> 
> It should be considered a _must_ to Q_DECLARE_TYPEINFO any type that is
> put
> into a QVector, QList or QVariant. In fact, my local copy enforces this
> at
> compile-time. I hope to push this work at some point, but of course,
> that
> means that each and every occurrence in Qt itself first needs to be
> fixed, and
> even then, we can only enable it as an opt-in to not break user code
> (even if
> it deserves to be broken).

So QQuickItem, for example, should have Q_DECLARE_TYPEINFO?

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.)?

> Thanks,
> Marc
> 
> --
> Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
> KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
> Tel: +49-30-521325470
> KDAB - The Qt Experts
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list