Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDataWidgetMapper with a QComboBox and a QSortFilterProxyModel

QDataWidgetMapper with a QComboBox and a QSortFilterProxyModel

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wowbagger
    wrote on last edited by
    #1

    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=1627

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

    Can anyone help me?

    1 Reply Last reply
    0
    • W Offline
      W Offline
      Wowbagger
      wrote on last edited by
      #2

      Has anybody a idea?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

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

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • W Offline
          W Offline
          Wowbagger
          wrote on last edited by
          #4

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

          It's QT 5.1.1 on Linux.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            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

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved