Hi.
I have the next SQLite table:
QSqlQuery table( QLatin1String( "CREATE TABLE IF NOT EXISTS contacts ( "
"marked INTEGER, contact TEXT, " "type TEXT, comment
TEXT )" ) );
And the next QSqlTableModel:
model = new QSqlTableModel( w, db );model->setTable( QLatin1String( "contacts"
) );model->setEditStrategy( QSqlTableModel::OnFieldChange );model->select();
I’m trying to insert new record to the table with:
QSqlRecord r;r.setValue( 0, 0 );r.setValue( 1, QString() );r.setValue( 2,
QString() );r.setValue( 3, QString() );if( !d->model->insertRecord( -1, r ) )
QMessageBox::critical( 0, tr( "Database Error..." ), tr( "Couldn't
insert new record into database.\n%1" ) .arg(
d->model->lastError().isValid() ?
d->model->lastError().text() : QString() ) );
But I received the error: “No Fields to update”. And new record wasn’t
inserted. I’ve tried to call d->model->insertRow( –1 ) but this failed too
without any error.
What am I doing wrong? Or may be it’s a bug?
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest