QDataWidgetMapper with a QComboBox and a QSortFilterProxyModel
-
Hi there,
I'm using QDataWidgetMapper to map a column from a QSortFilterProxyModel to a QComboBox.
@ QSqlRelationalTableModel *m_Model;
QSortFilterProxyModel *m_ProxyModel;
m_ProxyModel->setSourceModel(m_Model);mapper = new QDataWidgetMapper(this); mapper->setModel(m_ProxyModel); QSqlTableModel *relModel = m_Model->relationModel(typeIndex); projektComboBox->setModel(relModel); projektComboBox->setModelColumn(relModel->fieldIndex("projectID"); mapper->addMapping(projektComboBox, typeIndex);@
The values is displayed correctly in the ComboBox. But changes are not written to m_ProxyModel.
If I use the QSqlRelationalTableModel for mapping instead QSortFilterProxyModel for the mapping, everything works fine.
Another column mapped on a QLineEdit works fine with both: QSqlRelationalTableModel and QSortFilterProxyModel). Only QComboBox has the problem.
I posted a sample code in a german forum. You can download it here:
"Sample Code for the modelproblem":http://qtforum.de/forum/download/file.php?id=1627In the sample you can change the used model (QSqlRelationalTableModel/QSortFilterProxyModel) in line 23/24 in mainwindow.cpp
Can anyone help me?
-
Hi and welcome to devnet,
Which version of Qt are you using ? On which OS ?
-
Just tested in OS X and the behavior is the same.
Try checking the "bug report system":http://bugreports.qt-project.org to see whether it's a known issue. If not you could open a new bug report with this minimal compilable example