I am using the following approach to show the result of a select statement in the QTableView
. How should I modify this code to show the result of two or more different select statements in the same QTableView
?
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
QString dbPath = "test1.db";
db.setDatabaseName(dbPath);
QSqlQueryModel *model = new CustomSqlModel();
QSqlQuery* query = new QSqlQuery(db);
query->prepare("SELECT * FROM MyTable");
query->exec();
model->setQuery(*query);
model->setHeaderData(0, Qt::Horizontal, "Col1");
model->setHeaderData(1, Qt::Horizontal, "Col2");
model->setHeaderData(2, Qt::Horizontal, "Col3");
QTableView* tableView = new QTableView();
tableView->setModel(model);
I need to append the data selected from the same table in another database test2.db
to the data already shown in the tableView
.