Hi,
i'm loading a table in a sqlite db file through QSqlTableModel, but while the original table has 2847 records, the view shows only 2755. QSqlTableModel::lastError() does not report any issue.
How can I debug the problem? This is the code I'm using:
db.setDatabaseName(currentDatabase.absoluteFilePath());
if (!db.open()) {
QMessageBox::critical(this, qApp
->tr
("Error opening database"),
"Cannot connect to database.\n" + db.
lastError().
text(),
QMessageBox::Cancel);
return;
}
ui->tableView->setModel(tableModel);
tableModel->setTable("my_table");
tableModel->select();
ui->tableView->show();
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(currentDatabase.absoluteFilePath());
if (!db.open()) {
QMessageBox::critical(this, qApp->tr("Error opening database"),
"Cannot connect to database.\n" + db.lastError().text(), QMessageBox::Cancel);
return;
}
tableModel = new QSqlTableModel(this, db);
ui->tableView->setModel(tableModel);
tableModel->setTable("my_table");
tableModel->select();
ui->tableView->show();
To copy to clipboard, switch view to plain text mode
Thanks for any help
Bookmarks