> On Feb 14, 2014, at 3:59 PM, <igor.mironc...@gmail.com 
> <mailto:igor.mironc...@gmail.com>> <igor.mironc...@gmail.com 
> <mailto:igor.mironc...@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@qt-project.org <mailto:Interest@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





_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to