[Qt-interest] QSqlTableModel submitAll strange error

Rudolf Veliczky veliczky.rudolf at gmail.com
Mon Feb 15 11:48:23 CET 2010


Hi all,

i'm facing a strange error and need suggestions. We've an GUI application
that connects to a MySQL db. We're using QSqltableModel and QTableView to
display and manipulate data.
Originally the app was built with Qt4.3.2 opensource - QMySQL built as a
driver...
Now i rebuilt this app. using Qt4.4.3 (Mysql version remains the same and
QMySQL is again built as a driver).

Now the error:

Model's EditStategy is set to OnManualSubmit (for some specific reasons...).
Adding a new record, and deleting them are still OK, but unable to modify!
When editing data submitAll() returns false and lastError() holds strange
informations. databaseText is empty, number is not a valid number, isValid
is true and driverText is "No fields to Update" while model->isDirty()
returns true.

Delete code sample:
if ( ! mView->currentIndex().isValid() ) return;

  int row = mView->currentIndex().row();

QSqlRecord record = mModel->record(row);

if ( mModel->removeRows(row, 1) ) {

if ( mModel->submitAll() ) {

.....

works fine


Update code sample:

if ( ! mView->currentIndex().isValid() ) return;

int row = mView->currentIndex().row();

QSqlRecord record = mModel->record(row);


here come a few

         record.setValue("fieldname",updatedvalue)

calls

if ( mModel->setRecord(row, record) ) {

if ( ! mModel->submitAll() ) {

.....

returns false and mModel->lastError().text() is "No fields to update".



Any ideas?


Thanks

Rudolf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100215/dc612138/attachment.html 


More information about the Qt-interest-old mailing list