[Qt-interest] QSqlTableModel doesn't save new entries, editing works fine

Sven Grunewaldt strayer at olle-orks.org
Mon Feb 2 14:09:30 CET 2009


Am 02.02.2009 00:00, schrieb Tony Rietwyk:
> Svan wrote:
>
>    
>> Hi,
>>
>> I use a QSqlTableModel to display a simple SQLite database.
>> When I edit
>> an entry everything works correctly, but as soon as I want to add an
>> entry it doesn't "submit" the changes.
>> The row is added to the tableView and can be edited, but the
>> beforeInsert Slot won't be executed and there is no change to
>> the database.
>>
>> I'd appreciate any help, I'm at a total loss...
>>
>> Here is the part of the code I use:
>> <code sniped>
>>      
>
> Hi Sven,
>
> What is the EditStrategy setting?
>
> I found two problems when using IBASE - maybe similar things happen for
> SQLITE:
>
> - OnRowChange was not committing when selecting a new row until the new row
> was put into edit mode.
>
> - OnManualSubmit with my own commits still failed because the internal edit
> query was not being cleared when the manual transaction was committed on the
> database object. This only manifested when the same query was repeatedly
> executed - so insert, commit, edit, commit, insert was OK, but insert,
> commit, insert failed with "system error prevents execution" on the second
> insert.
>
> Having wasted many weeks on trying to get model based stuff working, I had
> to abandon them and do the DB grids myself! :O(
>
> Regards,
>
> Tony
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>    
I didn't change the EditStrategy, but using the Debug Dialog I found 
that it uses "OnRowChange".
Sadly I have no idea how to debug this problem... :/

Regards,
Sven Grunewaldt



More information about the Qt-interest-old mailing list