PDA

View Full Version : QDataWidgetMapper and QComboBox



scarleton
6th November 2010, 23:00
I have the classical QSqlRelationalTableModel situation where the customerModel is the master and the countryModel is the detail. The problem is that I don't want to display this model in a table, but show one record at a time in individual widgets using the QDataWidgetMapper.

How do I wire up the QComboBox that allows the user to pick the country?

Possible options:


Make the customerModel a QSqlTableModel, pass a 3rd param to the addMapper function
Make the customerModel a QSqlRelationalTableModel, wire up the relationship, and Qt does the rest.
something else

wysota
7th November 2010, 00:09
Use QSqlRelationalDelegate on the widget mapper.

scarleton
7th November 2010, 01:49
Ok, let me see if I understand what you mean.


the customerModel needs to be QSqlRelationalTableModel
Wire up the relationship to the countryModel
Create a QDataWidgetMapper
Make the mappers delegate the QSqlRelationalDelegate
Add a mapping for the QComboBox


Correct?

wysota
7th November 2010, 01:50
Yes, something like that.

scarleton
7th November 2010, 15:28
Tried that and it did not work :(