Куда ещё копать?
class ContactsModel: public QAbstractListModel
{
Q_OBJECT
public:
explicit ContactsModel(const QVector<Contact>& items, QObject* parent = nullptr)
: QAbstractListModel(parent)
_items(items)
{
}
int rowCount(const QModelIndex& parent = QModelIndex()) const override
{
return _items.size();
}
QVariant data(const QModelIndex& index, int role) const override
{
if(!index.isValid() ||
index.row() < 0 ||
index.row() >= _items.size())
{
return QVariant();
}
switch(role)
{
case Qt::DisplayRole:
...
}
return QVariant();
}
private:
QVector<Contact> _items;
};