Qt Sql :how can update data in different tables when i use qTableModel
Hi ,everyone! i am using qt sql to do a small software,but i encountered some difficulty;
i don't know how to update data in other table when i update one ;
eg: table A( name text , address text,primary key(name) );
table B(id integer,name references A(name),tel integer);
when i update field name in table A ,how can i update field name in table B, the point is that i use the QSqlTableModel to handle the data updating,
i find a signal called 'beforeUpdate' in QSqlTableModel,but it seems that the signal is emitted before update data in dataBase not before update data in model, so i come to look for help,my english is not good,thx!
Re: Qt Sql :how can update data in different tables when i use qTableModel
What do you mean by "update the field name"?
If two views are sharing the same QSqlTableModel then changes to the data in the table in one view will be visible in the other.
Re: Qt Sql :how can update data in different tables when i use qTableModel
sorry,i didn't make it clear. i mean using "update tableName set field=?"statement when i say update field name. and the 'table' is a sql table not a tableView , but the point is that i have only use a tableView and i want to update data cascade, and that means when i change one field which is the foreign key of another table,it is expected that the foreign key in another table also makes change. in the SQL manage ,there is something called "cascade",it's similar to this! anyway ,thanks!