QSqlQuery(批量插入)
//批量插入数据
QSqlQuery query;
query.prepare("insert into myTable values (?, ?)");
QVariantList ints;
ints << 1 << 2 << 3 << 4;
query.addBindValue(ints);
QVariantList names;
names << "Harald" << "Boris" << "Trond" << QVariant(QVariant::String);
query.addBindValue(names);
if (!query.execBatch())
{
qDebug() << query.lastError();
}
1