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

using qsortfilterproxymodel hides the match method of the underlying model

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Out of scope
    • Icon: P4: Low P4: Low
    • None
    • 4.6.2
    • Widgets: Itemviews
    • None
    • All

      I have this model 'A' that inherits from QAbstractItemModel and provides a reimplemetation of the 'match' method.

      This model is 'wrapped' by a QSortFilterProxyModel.

      When a keypress event is received in the ItemView that controls the QSortFilterProxyModel the match method gets called
      from within the ItemView's event handler.

      This calls the proxymodel's match which - by default - calls

      QAbstractProxyModel::match(start, role, value, hits, flags); // qsortfilterproxymodel.h line 1971

      Since QAbstractProxyModel does not implement a match, the match that gets called is the match as implemented in the
      QAbstractItemModel which does what it does.

      However My model 'A''s match should be called.

      Solution :

      implement QAbstractProxyModel::match(..) and call sourceModel()->match().

      If no match is implemented, then the QAbstractItemModel's will be called, otherwise the reimplemented version.

      Workaround :

      Inherit from QSortProxyModel and implement the above solution there.

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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            u19809 wim delvaux
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes