Problem with QSqlRelationalTableModel and submitAll()
I have a form with a tableview representing a QSqlRelationalTableModel and widgets linked to the same model via QDataWidgetMapper.
Here is the table structure:
@ queryString = QString("CREATE TABLE t100000_Stations ("
"RecordID INTEGER PRIMARY KEY AUTOINCREMENT,"
"StationID TEXT UNIQUE, "
"ProjectID TEXT, "
"LocalName TEXT, "
"StationType TEXT REFERENCES t911000_StationTypes(StationType), " // We have to link station type to a table (maybe parameters)
"Easting DOUBLE NOT NULL, "
"Northing DOUBLE NOT NULL, "
"Latitude DOUBLE, "
"Longitude DOUBLE, "
"LatLonDatum TEXT, "
"CoordinateSystem TEXT, "
"Elevation DOUBLE, "
"ElevationType INTEGER REFERENCES t908000_ParameterTypes(ParameterID), " // Same here
"ElevationDatum TEXT, "
"SurveyMethod TEXT, "
"Surveyor TEXT, "
"SurveyDate DATETIME, "
"LandTenure TEXT, "
"Region TEXT, "
"MiningLease TEXT, "
"Source TEXT NOT NULL, "
"SourceDate DATETIME NOT NULL, "
"EntryAuthor TEXT NOT NULL, "
"EntryDate DATETIME NOT NULL)"
The form shows the records and relations flawlessly, including combo boxes and table view delegates for the relation fields.
My problem is that any edits in the table values are not passed back to the database.
After much trying, I end up changing the setEditStrategy to OnManualSubmit.
I added a submitAll() call in the form destructor to update the database, but it returns false and give me the following error message:
"near ".": syntax error Unable to execute statement"
I saw in somepage that it could be related to the primary key. I did the following command in debug mode:
@QString tempString = tableModelStations->primaryKey().name();@
but the string came empty, which make me believe that the problem indeed was in the primary key.
I then subclassed QSqlRelationalTableModel so that I could implement the setPrimaryKey() function and do it manually, but no luck with that either.
Could anyone shed some light on:
- Why submitAll() isn't working
- How to access the statement used by submitAll()
Thanks in advance,