QSqlRelationalTableModel/QDataWidgetMapper and empty model
I have a working model and mapper (Qt4.7) and the values are shown in several widgets (lineedits,combos).
The connections are made with "addMapping".
If i set a filter (model->setFilter("...")) to my modell which leads to zero data in the model, my widgets are not cleared.
They keep their values from the last entry before setting the filter.
How can i solve this ?
Thanks in Advance
An index problem?
@QModelIndex index = tableView->currentIndex();
widgetMapper->setCurrentIndex( index.row() );@
I think you have to inform the mapper that the index is no more valid, so it can clean the widgets.
Now I found out something strange. Some widgets are cleared and some are not !
My model connects to an Access-mdb. All fields which are text-type are cleared correctly, but all other fields like numbers, date or currency keep their values of before.
This is the same behaviour if i add a new row.
How can i handle these datatypes the same way like the textfields ?
You can reproduce this problem by modifying the Qt Example "SQL Widget Mapper"
If you add these lines to the example and connect it with a new button you can see that the widgets stay like they are (not cleared), but the model ist empty because of the filter.
Please help !
Solution ! revert() did the job :
Have you got this line?: