[Qt-interest] QSqlRelationalTableModel - Refreshing relation
Jan
janusius at gmx.net
Sat May 29 15:25:08 CEST 2010
afaik there is no way to update the relationmodel ("dictionary") that is
used internally (take a look at the qt source).
I think you have to "reset" the model and all relations (that is what I
am doing).
Jan
Am 28.05.2010 23:12, schrieb Harry Sfougaris:
> 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
>
>
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
More information about the Qt-interest-old
mailing list