[Interest] QSqlTableModel remove row
Mark Brand
mabrand at mabrand.nl
Sat Feb 15 14:28:03 CET 2014
> On Feb 14, 2014, at 3:59 PM, <igor.mironchik at gmail.com
> <mailto:igor.mironchik at gmail.com>> <igor.mironchik at gmail.com
> <mailto:igor.mironchik at gmail.com>> wrote:
>
>> Hi.
>> How to correctly remove row from QSqlTableModel?
>> I’ve used removeRow() and removeRows() but they are half-worked. They
>> remove row from the database table and in the view I see that data is
>> gone, but empty row in the view is still displayed...
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org <mailto:Interest at qt-project.org>
>> http://lists.qt-project.org/mailman/listinfo/interest
>
>
> On 02/14/2014 10:42 PM, Karl Ruetz wrote:
>
> One possible way would be to connect the rowsRemoved signal for the
> model to a slot that calls model.select() or some other function that
> resets the model and updates the view.
>
> Karl
The deleted row remains in the model after being submitted. Internally,
selectRow() refreshes just the row that was submitted. This gives you
the opportunity to revert or retry a failed delete operation.
As pointed out by Karl, select() resets the whole model. However,
instead of connecting this to the rowsRemoved() signal, it might be
better to reimplement selectRow() to make it call select() if that is
what you want.
Another possibility is to use OnManualSubmit edit strategy, which always
uses select() (rather than selectRow()) after submitting.
Mark
More information about the Interest
mailing list