JD2000
26th November 2009, 19:05
I have a tree, populated from an SQL database with
model = new QSqlQueryModel(this);
model->setQuery("SELECT * FROM people ORDER BY Name");
model->setHeaderData(0, Qt::Horizontal, tr("ID"));
model->setHeaderData(1, Qt::Horizontal, tr("Name"));
TreeView->setModel(model);
TreeView->show();
The 'ID' is the primary key of the 'people' table in the database.
My question is how do I show the tree with a given 'ID' / record already selected?
eg after a new record has been inserted into the table and its 'ID' retreived with something like
query.lastInsertId().toString();
model = new QSqlQueryModel(this);
model->setQuery("SELECT * FROM people ORDER BY Name");
model->setHeaderData(0, Qt::Horizontal, tr("ID"));
model->setHeaderData(1, Qt::Horizontal, tr("Name"));
TreeView->setModel(model);
TreeView->show();
The 'ID' is the primary key of the 'people' table in the database.
My question is how do I show the tree with a given 'ID' / record already selected?
eg after a new record has been inserted into the table and its 'ID' retreived with something like
query.lastInsertId().toString();