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

[REG] QSortFilterProxyModel::reset() does nothing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 4.8.x
    • 4.7.0
    • Widgets: Itemviews
    • None
    • Win7 x86, MSVC2010, Qt4.7.0

      The official Qt documentation contains the following passage for QSortFilterProxyModel:

      If you are working with large amounts of filtering and have to invoke invalidateFilter() repeatedly, using reset() may be more efficient, depending on the implementation of your model. However, reset() returns the proxy model to its original state, losing selection information, and will cause the proxy model to be repopulated.

      My model contains 10 columns and up to 1 million rows. I'm using reset() instead of invalidateFilter() because in my case the call of reset() is really so much faster than the call of invalidateFilter(). This works for me very fine with Qt4.5.x and Qt4.6.x.

      Now, since Qt4.7.0, it does no longer work, because the call of reset() does nothing. You can easily reproduce this bug by editing the official Qt Example "customsortfiltermodel" that comes with the Qt libraries. In this example, you only need to replace "invalidateFilter" by "reset" in both functions, setFilterMinimumDate and setFilterMaximumDate. Then you will see, that the filter function doesn't work.

      The official Qt documentation of QAbstractItemModel::reset(), (inherited by QProxyModel that is inherited by QSortFilterProxyModel) contains this passage:

      Use beginResetModel() and endResetModel() instead whenever possible. Use this method only if there is no way to call beginResetModel() before invalidating the model. Otherwise it could lead to unexpected behaviour, especially when used with proxy models.

      I've played with beginResetModel() and endResetModel() instead of reset(), but without success. The only way to update the model due to filter changes is the call of invalidateFilter() and this function is very slow on models with more than 50000 rows.

      I hope you can fix the problem, so that it is possible again to use reset() instead of invalidateFilter().

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

            stephen.kelly Stephen Kelly (Unused account) (Inactive)
            rene René Keimling
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes