PDA

View Full Version : QDataWidgetMapper question



larry104
24th July 2007, 15:01
Has anyone played with the QDataWidgetMapper in releation with a QSqlRelationalTableModel. In other words having an input mask for various table fields as well as showing the full table. When I insert a new record into the table it looks like the mapper is not submitting the data correct when using
mapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit);

Thanks.

jpn
25th July 2007, 07:28
Exactly in what way does it not work correctly? I know it's a lot asked but could you prepare a minimal compilable example (which eg. creates a sqlite test db in memory) reproducing the problem so we could give it a try?

larry104
26th July 2007, 12:29
Hi,

I attached the modified Qt books demo and you see the problem. Insert a new row and try to fill the fields. I also found the problem while I prepared that example. When you use

model->setEditStrategy(QSqlTableModel::OnFieldChange);

instead of


model->setEditStrategy(QSqlTableModel::OnManualSubmit);

you will notice that the when the fields get changed the are not changed in the table. Can someone explain to me the different behavior?

Thanks in advance.

larry104
26th July 2007, 15:30
Another strange thing is when you use a mysql database and delete all rows (I added an delete button to the code example) you will have an empty row in the table left - QSQLITE will not show this problem.

And one last thing I noticed if you insert a row but do not submit (the table will show *) the mapper works not correct (values will not be shown in the table)

So, three open questions. I appricate any help.
Many thanks