PDA

View Full Version : Updating data in table view when related table is changed



blindman
3rd June 2011, 10:07
Consider the following scenario: I have 2 database tables, table1 and table2

create table table1 (id int, name varchar(100));
create table table2 (id int, name varchar(100), table1_id int);

I use QSqlTableModel + QTableView to display id and name from table1, and
QSqlRelationalTableModel + QTableView to display id and name from table2, and related name from table1.

How do I make QTableView showing data from table2 pick up the changes made to table1 to display updated table1.name?

high_flyer
8th June 2011, 15:13
This should be done out of the box by Qt if you are using the data view architecture correctly.