Allowed item types

Not all types can be put in containers. All containers can only hold types that provide a default constructor, a copy constructor, and an assignment operator. All primitive types and most Qt data types (such as QString or QPointF) satisfy these requirements. Simple structs also can be stored in a container because the required constructors and operators are generated for them automatically, as per C++ standard.

A particular type usually cannot be put in a container because it doesn't have a constructor without arguments or copying this type was deliberately disabled. This is actually the case for QObject and all its descendants. The usage patterns of QObject suggest that you usually want to store pointers to a QObject

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.