Nominate our 2022 Qt Champions!

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;

    mapper = new QDataWidgetMapper(this);
    QSqlTableModel *relModel = m_Model->relationModel(typeIndex); 
    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":

    In the sample you can change the used model (QSqlRelationalTableModel/QSortFilterProxyModel) in line 23/24 in mainwindow.cpp

    Can anyone help me?

  • Has anybody a idea?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Which version of Qt are you using ? On which OS ?

  • bq. Which version of Qt are you using ? On which OS ?

    It's QT 5.1.1 on Linux.

  • Lifetime Qt Champion

    Just tested in OS X and the behavior is the same.

    Try checking the "bug report system": to see whether it's a known issue. If not you could open a new bug report with this minimal compilable example

Log in to reply