Chapter 8. Container Classes
Container classes were one of the first types of classes that were put into class libraries. Container classes are used for objects that contain other objects, such as arrays or lists. Most GUI class libraries have included container classes.
Note that if you have experience in other programming languages that are commonly used for GUI programming, such as Java, you might understand the notion of “container” differently. In the Java AWT, containers are objects that can hold other GUI objects. In Qt, there is no such difference; every GUI object can hold other GUI objects, even though it does not always make sense. For example, having a button contain other GUI objects would be of no use. Qt uses the classic C++ notion of container classes that can hold other objects in the sense of memory references, not in the more specific sense of general containment.
With the advent of the C++ standard, another library with container classes, the Standard Template Library (STL), has been included in the standard. This standard will lead to all compiler vendors including it.
Nevertheless, it still pays to learn how to use Qt’s own container classes. STL is not easy to learn, and when all you want to do is put some strings in a list and iterate over it, you can just as well use the Qt classes. Of course, these classes are not as sophisticated as the STL classes, and there aren’t quite as many of them. However, if Qt contains what you need, I would suggest giving ...
Get Programming with Qt, 2nd 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.