Qt
0
Вклад в тег
QVariant DynamicSqlTableModel::data(const QModelIndex &index, int role) const {
if (role == Qt::DisplayRole) {
initializePackageByRow(index.row());
return data_list[index.row()].value(index.column());
}
return QVariant();
}
void DynamicSqlTableModel::initializePackageByRow(int row) const {
for (int i = data_list.size(); i <= row; i+= package_size) {
QString package_query = setLimit(query, QString("%1, %2").arg(i).arg(package_size)); //моя строковая ф-я
QSqlQuery q = QSqlQuery();
q.setForwardOnly(true);
if (!q.exec(package_query)) {
emit error(logger(q, LOG));
return;
}
while(q.next())
data_list.push_back(q.record());
}
}