[Qt-interest] QSqlTableModel submitAll strange error
Jan
janusius at gmx.net
Mon Feb 15 12:32:38 CET 2010
Why are you using records? I suppose it is better to use setData
function of QSqlTableModel.
Jan
Rudolf Veliczky schrieb:
> 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
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list