Note that there are some explanatory texts on larger screens.

plurals
  1. POQDataWidgetMapper only updates first index to QSqlRelationalTableModel
    primarykey
    data
    text
    <p>I have a problem regarding parts of the QT framework. I am using QT 5.0.2 and am developing on Windows at the moment.</p> <p>In my application I have a Tableview set up with a QSqlRelationalTableModel. Next to it I have a text field and 3 combo boxes connected to the relational table model. The widgets are mapped to the model using QDataWidgetMapper as follows:</p> <pre><code>mapper = new QDataWidgetMapper(this); mapper-&gt;setModel(model); mapper-&gt;setItemDelegate(new QSqlRelationalDelegate(this)); mapper-&gt;setSubmitPolicy(QDataWidgetMapper::ManualSubmit); mapper-&gt;addMapping(ui-&gt;courseComboBox, model-&gt;fieldIndex("course_shortcode")); mapper-&gt;addMapping(ui-&gt;subjectComboBox, model-&gt;fieldIndex("subject_name")); mapper-&gt;addMapping(ui-&gt;lecturerComboBox, model-&gt;fieldIndex("lecturer_name")); mapper-&gt;addMapping(ui-&gt;themesTextEdit, model-&gt;fieldIndex("event_themes")); </code></pre> <p>As you see the SubmitPolicy is set to manual submit. Under the widgets i have a buttonbox containing a save and a reset button.</p> <p>When the save button gets clicked, I do this:</p> <pre><code>qDebug() &lt;&lt; this-&gt;mapper-&gt;submit(); qDebug() &lt;&lt; model-&gt;lastError().text(); </code></pre> <p>This will create the following output:</p> <pre><code>true " " </code></pre> <p>Which means the submit was successful and there was no error reported.</p> <p>Nevertheless only the first field gets updated in the model. All the other widgets reset their value to the value from the original model (because the model emits datachanged, which the mapper connected itself to, I guess).</p> <p>I tried removing one or 2 of the mappings and always onl the field whichs mapping gets added first will be updated.</p> <p>If I change the submitPolicy to autoSubmit the mapper does its work as intended. But I really need to have those reset and apply buttons and not have the data get submitted on change.</p> <p>This seems like an occurrence of <a href="https://bugreports.qt-project.org/browse/QTBUG-1086" rel="nofollow">QTBug 1086</a> but that bug got fixed and I cant reproduce the problem from the bug report from the code there either.</p> <p>I hope you can help me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload