Game Programming using Qt 5 Beginner's Guide - Second Edition
by Pavel Strakhov, Witold Wysota, Lorenz Haas
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
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access