My application stores a few objects of a type that inherits from
QAbstractListModel
objects.
This generates quite a lot of duplicated code when wrapping a simple
std::vector<T>
or a QList<T>
into model with the general add,
delete and multi-selection functionality.
Is that the way QAbstractListModel
is supposed to be used or is there
some adapter class that can remove the duplicated code (at least for
containers that are part of Qt)?
Example: I want to wrap vector<ObjectA>
and vector<ObjectB>
into a model. The code for insertRows
, deleteRows
, columnCount
etc. is always going to be the same and I would like to consolidate that (with a little meta-programming that could even work for with tuple
and data
).