#include "towermodel.h" TowerModel::TowerModel(QList mtowers, QObject *parent) : QAbstractListModel(parent) { towers = mtowers; } void TowerModel::refresh(QList mtowers) { towers = mtowers; } int TowerModel::rowCount(const QModelIndex &) const { return towers.count(); } QVariant TowerModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); if (index.row() >= towers.size()) return QVariant(); if (role == Qt::DisplayRole) { return towers.at(index.row()).name; } return QVariant(); }