Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, April 2008
QDataWidgetMapper and multiple joined tables


Message 1 in thread

I need to display several controls on the same form; the fields 
connected to the controls came from 3 different tables; one is the 
"main" table and the other are linked using foreign keys. Is there a way 
to use QDataWidgetMapper also to display the data coming from the other 
2 tables? Is there any code example?
begin:vcard
begin:vcard
fn:Massimo Manca
n:Manca;Massimo
org:Micron Engineering di Massimo Manca
adr:;;via della Ferriera, 48;Pordenone;PN;33170;ITALIA
email;internet:massimo.manca@xxxxxxxxxxxxxxxxxxxx
tel;work:+39 0434 1856131
tel;fax:+39 0434 1851032 / 178 273 3543
tel;cell:+39 349 4504979
url:http://www.micronengineering.it
version:2.1
end:vcard


Message 2 in thread


"Massimo Manca" <massimo.manca@xxxxxxxxxxxxxxxxxxxx> schreef in bericht 
news:480A9085.8020303@xxxxxxxxxxxxxxxxxxxxxxx
> I need to display several controls on the same form; the fields
> connected to the controls came from 3 different tables; one is the
> "main" table and the other are linked using foreign keys. Is there a way
> to use QDataWidgetMapper also to display the data coming from the other
> 2 tables? Is there any code example?
>
Did you look into using QSqlRelationalTableModel for your model?

André 

--
 [ signature omitted ] 

Message 3 in thread

> Sent: Sunday, 20 April 2008 10:38
> 
> I need to display several controls on the same form; the fields 
> connected to the controls came from 3 different tables; one is the 
> "main" table and the other are linked using foreign keys. Is 
> there a way 
> to use QDataWidgetMapper also to display the data coming from 
> the other 
> 2 tables? Is there any code example?

Hi Massimo, 

I don't think QDataWudgetMapper can handle multiple models. I think you need
to use: 

- QSqlTableModel for the master table. 
- QSqlRelationalTableModel for the two detail tables. 
- 3 separate QDataWidgetMappers - one for each model. 

You may need to coordinate the updates yourself, but that depends on the
settings. 

Hope that helps, 

Tony Rietwyk

--
 [ signature omitted ] 

Message 4 in thread

Tony Rietwyk wrote:

> I don't think QDataWudgetMapper can handle multiple models. I 
> think you need
> to use: 
> 
> - QSqlTableModel for the master table. 
> - QSqlRelationalTableModel for the two detail tables. 
> - 3 separate QDataWidgetMappers - one for each model. 

No. He should be able to use one QSqlRelationalTableModel for the master
table AND the two detail tables, and QDataWudgetMapper then can handle
this one model!

Cheers,
Peter

--
 [ signature omitted ]