[Qt-interest] QSqlRelationalTableModel - Refreshing relation
Harry Sfougaris
hsfougaris at gmail.com
Fri May 28 23:12:27 CEST 2010
If I have a relation set in a QSqlRelationalTableMode, how can I refresh the relation?
For example, given the following code:
QSqlRelationalTableModel *tbl = new QSqlRelationalTableModel(this);
tbl->setTable("master_data");
tbl->setRelation(tbl->fieldIndex("detail_id"), QSqlRelation("detail_data", "id", "detail_descr"));
tbl->select();
If at a later point data is added to the table "detail_data", how can I refresh the relation?
I am using it in a combo like this (in a form that edits the data):
QSqlTableModel *tbl2= tbl->relationModel( tbl->fieldIndex("detail_descr") );
ui->tbl2Combo->setModel(tbl2);
ui->tbl2Combo->setModelColumn( tbl2->fieldIndex("detail_descr") );
and I can't get the new values in the combo, unless I close and reopen the main table.
Thanks
Harry Sfougaris
More information about the Qt-interest-old
mailing list