Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-39046

QDataWidgetMapper with a QComboBox and a QSortFilterProxyModel doesn't work

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.2.1, 5.13.1
    • Fix Version/s: None
    • Component/s: SQL Support
    • Labels:
      None
    • Environment:
      Linux

      Description

      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 upload a sample: "modelproblem.zip".

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

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            mabrand Mark Brand
            Reporter:
            wowbagger Christian Hilk
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes