I need to implement a QAbstractListModel subclass so i can use a QListView with a domain class of our project.
The documentation covers nicely what methods i have to provide, but what baffles me is that there is no obvious way to retrieve the original object for a specific QModelIndex.
What i am looking for is something like this:
model MyModel<MyDomainEntity>(listOfDomainEntities);
model.item(someIndexComputedFromSelection); // Should return a MyDomainEntity
or
MyDomainEntity ent = model.data(someIndexComputedFromSelection, Qt::ItemRole)
.value<MyDomainEntity>();
But i can't find any easy way to do that, besides implementing these model methods myself. Am i missing something?