[Qt-interest] QSqlRelationalTableModel - Refreshing relation

Harry Sfougaris hsfougaris at gmail.com
Sat May 29 16:10:50 CEST 2010


I was afraid of that...
So you are basically talking about setting the relation and calling select() again, or is there something more clever I could do?


Harry Sfougaris

Sent from my iPhone

On 29 Μαϊ 2010, at 16:25, Jan <janusius at gmx.net> wrote:

> 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
>> 
> _______________________________________________
> 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