sqlite: QTreeView + QSqlTableModel
Solved
General and Desktop
-
Hi!
I have two tables in DB. There is 'one to multiple' connection.
I need to:- Show the main table.
- Show the second table by row selection of the main table.
- Needs to customization of the main table header: QLineEdit for each columns for filtering.
//Table1 model1 = new QSqlTableModel(this); model1->setTable("table1_t"); model1->setEditStrategy(QSqlTableModel::OnManualSubmit); model1->select(); model1->setHeaderData(0, Qt::Horizontal, tr("Col1")); model1->setHeaderData(1, Qt::Horizontal, tr("Col2")); ui->view1->setModel(model1); //Table2 model2 = new QSqlTableModel(this); model2->setTable("table2_t"); model2->select(); model2->setHeaderData(0, Qt::Horizontal, tr("Col1")); model2->setHeaderData(1, Qt::Horizontal, tr("Col2")); model2->setHeaderData(2, Qt::Horizontal, tr("Col3")); ui->view2->setModel(model2);
How to connect view1 and view2 between each other?
Thank you! -
@sitesv said in sqlite: QTreeView + QSqlTableModel:
How to connect view1 and view2 between each other?
See the selectionChanged() signal