[Development] Regression / Behavioral Change in QSqlTableModel / QTableView in Qt 5

Maemi Carrer maemicarrer at gmail.com
Thu Aug 30 12:46:10 CEST 2012


Thank you for your response!

2012/8/14 Mark Brand <mabrand at mabrand.nl>:
> QSqlTableModel has had some major changes for Qt5. The changes file
> "dist/changes-5.0.0" lists them.

I totally missed that.

> ... each edit causes the table to be requeried and the model reset, which
> breaks navigation in the view.

Do you mind elaborating in which way this breaks navigation?

> It sounds like you are using OnFieldChange or OnRowChange strategy. This is
> by design. The deleted row remains in the cache until select() is called
> again.

I see. Is there any possibility to update the model (so the row is removed in
the view, not just cleared out) without 'resetting' the model using select()?

I just want to have the row deleted (yes, at the cost of losing navigation and
selection in the view), but without having to repopulate the data from the
database (which is implied by select()).

>> Inserations for example using insertRecord() are not reflected as well
>> (no visible changes in the view, although data is added to the table).
> This is not the expected behavior and I cannot reproduce it. Can you provide
> an example?

I tried to boil down the code to a simple example and I now can nail down the
problem. It only affects tables having an AUTOINCREMENT primary key, causing
an empty row to be inserted (with an exclamation mark in the view, same as
for a deleted row) and a select() is required to get the actual data
into the view
(and obviously the model as well).

Tables having a primary key not beeing AUTOINCREMENT (although they are
set by the database as well) seem to be not effected (data is shown
immediately).


br
Maemi



More information about the Development mailing list