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

QStandardItemModel presents bad data to QSortFilterProxyModel on update

    XMLWordPrintable

Details

    Description

      The following example will have in invalid index as the input to QSortFilterProxyModel::filterAcceptRow().

      #include <QtGui>

      class Filter : public QSortFilterProxyModel
      {
      public:
      Filter(QObject *parent = 0)
      : QSortFilterProxyModel(parent)
      {}
      virtual bool filterAcceptsRow(int row, const QModelIndex &parent) const

      { qDebug() << row << parent << "isValid" << sourceModel()->index(row, 0, parent).isValid(); return true; }

      };

      int main(int argc, char *argv[])
      {
      QCoreApplication app(argc, argv);

      QStandardItemModel model;
      Filter proxy;
      proxy.setSourceModel(&model);

      QList<QStandardItem *> rows;
      rows.append(new QStandardItem("foo"));
      model.appendColumn(rows);
      return 0;
      }

      I would not have expected isValid() to return false.

      Update: You can work around this bug by appending rows one at a time instead of appending one column list.

      Attachments

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

        Activity

          People

            bjnilsen Bjørn Erik Nilsen
            rve Anders Bakken
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes