21 lines
530 B
C++
21 lines
530 B
C++
#include "SociModel.h"
|
|
|
|
SociModel::SociModel(QObject* parent, QSqlQuery& query) : QAbstractTableModel(parent), query(query) {
|
|
;
|
|
}
|
|
|
|
int SociModel::rowCount(const QModelIndex&) const {
|
|
return query.size();
|
|
}
|
|
|
|
int SociModel::columnCount(const QModelIndex&) const {
|
|
return query.record().count();
|
|
}
|
|
|
|
QVariant SociModel::data(const QModelIndex& index, int role) const {
|
|
if (role == Qt::DisplayRole) {
|
|
query.seek(index.row());
|
|
return query.value(index.column()).toString();
|
|
}
|
|
return QVariant();
|
|
} |