Hi,
I have a custom function inside a reimplementation of QSqlTableModel that intents to change a field value after the insertion. I insert the new record with:
newRecord = mymodel->record();
newRecord.setValue("CURRCODE","TestValue");
mymodel->insertRecord(-1,newRecord);
mymodel->updateNewRecord(); //Custom function
QSqlRecord newRecord;
newRecord = mymodel->record();
newRecord.setValue("CURRCODE","TestValue");
mymodel->insertRecord(-1,newRecord);
mymodel->updateNewRecord(); //Custom function
To copy to clipboard, switch view to plain text mode
Inside the model, the custom function updateNewRecord has:
qDebug() << "Previous Value: " << record(this->rowCount()-1).value("CURRCODE").toString(); //Prints "TestValue"
record(this->rowCount()-1).setValue("CURRCODE","Newvalue"); //Setting a new value
qDebug() << "New Value: " << record(this->rowCount()-1).value(codeColumn).toString(); //Prints "TestValue"!!!
qDebug() << "Previous Value: " << record(this->rowCount()-1).value("CURRCODE").toString(); //Prints "TestValue"
record(this->rowCount()-1).setValue("CURRCODE","Newvalue"); //Setting a new value
qDebug() << "New Value: " << record(this->rowCount()-1).value(codeColumn).toString(); //Prints "TestValue"!!!
To copy to clipboard, switch view to plain text mode
The problem is that after setting the value with setValue()I still have the old value ("TestValue")!!!
Any idea why?
Thanks,
Carlos.
Bookmarks