PDA

View Full Version : How to avoid selection changes on a QTableView displaying a OnFieldChange edit model?



hickscorp
7th June 2011, 16:21
Hello,

i have a fairly simple model (QSqlTableModel based) being displayed by a QTableView.
i provide buttons to insert rows at the end of the existing, basically just doing that:


QSqlRecord r = _dtModel->record();
r.setNull ("id");
r.setValue ("name", "New Document Type");
r.setValue ("micr", 0);
r.setValue ("code", 0);
_dtModel->insertRecord(-1, r);
However, upon adding a type, i loose the previous table selection...

Why, and how to prevent that (And i dont really want to re-select previously selected items because it involves a lot of other table queries, i'd rather want to just *avoid* loosing the current selection)?

Thanks,
Pierre.