qlands
26th July 2011, 08:43
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:
QSqlRecord newRecord;
newRecord = mymodel->record();
newRecord.setValue("CURRCODE","TestValue");
mymodel->insertRecord(-1,newRecord);
mymodel->updateNewRecord(); //Custom function
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"!!!
The problem is that after setting the value with setValue()I still have the old value ("TestValue")!!!
Any idea why?
Thanks,
Carlos.
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:
QSqlRecord newRecord;
newRecord = mymodel->record();
newRecord.setValue("CURRCODE","TestValue");
mymodel->insertRecord(-1,newRecord);
mymodel->updateNewRecord(); //Custom function
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"!!!
The problem is that after setting the value with setValue()I still have the old value ("TestValue")!!!
Any idea why?
Thanks,
Carlos.