I have subclassed QSqlTableModel and overridden data() and setData() to do unit conversion. That is, I want to multiply value by user-specified multiplier when going into db, and divide by the same multiplier when showing that field in the UI. However, for some reason setData() doesn't get called except for initially populating the fields.
Result: every time I click on a field in the UI, the conversion in data() gets done and the value divided, without it having been multiplied first in setData(). Clicking the field again and again, the field eventually reaches zero value.
What affects if setData() is called?
When I look at stack trace that reaches my data(), it seems QSqlTableModel::setData DOES get called each time, just not my function. I am submit()ing the changes every time setData is called so that ought not be the issue.
Aucun commentaire:
Enregistrer un commentaire