By looking at our first use case (Add character to characters list
), we will note that an entity representing a list of characters is involved. Our characters entity needs a few methods: at least one to add an item to the list, and one to retrieve the items in the list. We will thus keep things simple and implement the entity as a list, without additional members. The list is quite simple, requiring only a character's name to be used for the use cases here.
The first option would be to implement the list with a simple QList
of QStrings
or QVariants
, as we did in Chapter 2, Defining a Solid and Testable App Core. However, Qt provides more powerful data structures that make it easier to implement the model/view paradigm. All these models derive from QAbstractItemModel
, provide automatic means of updating the views that rely on them, and can conveniently represent relatively complex data structures, such...