PDA

View Full Version : Accept data in a editing widget



woodtluk
5th October 2011, 15:26
Hi there

I'm making a small application that represents a to-do list. The list is stored in a cusom model (derived from QAbstractItemModel) and is displayed in a QTableView.

I have also a custom widget (TaskDialog) that is used to browse and edit tasks from the list. The children of the TaskDialog are mapped to the model with a QDataWidgetMMapper. On the task dialog I have also buttons that allow browsing through all the tasks in my to-do list (QDataWidgetMapper::toPrevious() ...).

The problem is that if I'm editing a task in the TaskDialog (e.g. the tasks name) and then browse to another task, the new edited enty isn't set in the model. But if I edit something in the TaskDialog, then first change the focus to an other child widget of the TaskDialog and then press one of the browsing button, than the changes are written to the model.

How can I achive that widgets that are in a editing mode are accepted and written to the model.

I also tried the example of QDataWidgetMapper from Nokia. There it works perfectly. But they use a QStandardItemModel.

Best regards Luke

wysota
5th October 2011, 16:46
I'd have to see the code but it seems the behaviour is related to submit policy of the widget mapper. You should make sure accepting the dialog submits the data to the mapper and prior to doing that set the mapper's submit policy to Manual.

woodtluk
5th October 2011, 22:37
Thank you very much!

It seems to work!!!