The obvious response is that a single model may serve multiple views and not all views necessarily need (or even should if columns are restricted to certain users) to show everything in the model. It can also be useful to have a column that is hidden in release version but visible during debug (e.g. an underlying database ID).If you don't want to show, why to have it in first place???
You can call setData() on model indexes that reference columns that a view is not showing. You do need to work out exactly where (inside or outside the model) and when (on insert only, update only, both, what about delete or new rows as yet uncommited) the value should be changed. Inside the model: do anything you like in the model's setData(), just make sure the relevant signals are emitted so views stay synchronised. Outside the model: if you have a delegate on the table then setModelData() may be a good place. If you are referring to commiting to an underlying database then the QSqlTableModel::beforeInsert(), beforeUpdate(), and primeInsert() signals can be useful.i would like to know if there is a way to change the invoice_id column value for each row before commiting thanks in advance?
Bookmarks