I'm currently working on a project and I'm quite new to Qt and SQLITE. I currently have an integer array and would like to use it to obtain data linked to the elements in the array. For example, if the data is 61616, it will output Sarah.
query.prepare("SELECT name,memberType FROM members WHERE id = :id");
for(index = 0; index < dateIndex; index++)
{
id = idAr[index];
query.addBindValue(id);
query.exec();
}
model2->setQuery(query);
ui->tableView_10->setModel(model2);
I know this is wrong. Can someone explain how to properly do this?
Update:
std::vector<int> idA={3, 7, 15, 16, 19, 30};
QSqlQuery qry(QString("SELECT name, memberType FROM members WHERE id IN (?%1)")
.arg(QString(", ?").repeated(idA.size()-1)));
for(int i = 0; i < idA.size(); i++)
{
int id2 = idA[i];
qry.addBindValue(id2);
}
qry.exec();
model2->setQuery(qry);
ui->tableView_10->setModel(model2);
However, it still does not output to the table.