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

Tony Rietwyk tony.rietwyk at rightsoft.com.au
Mon Feb 2 00:00:07 CET 2009


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





More information about the Qt-interest-old mailing list