c++ - QDataWidgetMapper only updates first index to QSqlRelationalTableModel -


i have problem regarding parts of qt framework. using qt 5.0.2 , developing on windows @ moment.

in application have tableview set qsqlrelationaltablemodel. next have text field , 3 combo boxes connected relational table model. widgets mapped model using qdatawidgetmapper follows:

mapper = new qdatawidgetmapper(this); mapper->setmodel(model); mapper->setitemdelegate(new qsqlrelationaldelegate(this)); mapper->setsubmitpolicy(qdatawidgetmapper::manualsubmit); mapper->addmapping(ui->coursecombobox, model->fieldindex("course_shortcode")); mapper->addmapping(ui->subjectcombobox, model->fieldindex("subject_name")); mapper->addmapping(ui->lecturercombobox, model->fieldindex("lecturer_name")); mapper->addmapping(ui->themestextedit, model->fieldindex("event_themes")); 

as see submitpolicy set manual submit. under widgets have buttonbox containing save , reset button.

when save button gets clicked, this:

qdebug() << this->mapper->submit(); qdebug() << model->lasterror().text(); 

this create following output:

true  " "  

which means submit successful , there no error reported.

nevertheless first field gets updated in model. other widgets reset value value original model (because model emits datachanged, mapper connected to, guess).

i tried removing 1 or 2 of mappings , onl field whichs mapping gets added first updated.

if change submitpolicy autosubmit mapper work intended. need have reset , apply buttons , not have data submitted on change.

this seems occurrence of qtbug 1086 bug got fixed , cant reproduce problem bug report code there either.

i hope can me.

i edited answer because misunderstood documentation and, after receiving explanation, got correct way obtain desired result. should modify model edit strategy using qsqltablemodel::seteditstrategy() , change qsqltablemodel::onrowchange. needed in order avoid modifications sent underlying db after every single column modification, produce update of mapped widgets contents after first column change.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -