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

QSortFilterProxyModel: Indexes returned by match() cannot be used to select in view

    XMLWordPrintable

Details

    • Windows
    • b01248ebbd42dd05d45fa655852169978beec40e (qt/qtbase/5.12)

    Description

      I have a QSortFilterProxyModel as a QTreeView's model (qtbug73864.zip). I use search functionality for the view and use match() function to get indexes that matches search results.

      If I set the index from match() results as a current index in view's model, the index is not highlighted.

      If I map the index to an index from sourceModel (mapToSource) and then use that index to map to an index in proxyModel (mapFromSource, because proxyModel is used as view's model) and use that to select current item, it works.

      Note: It works when typing a search text from the top row or from the first column ("Containers", "General")

      Please find the attached example app to demonstrate this behavior. The match functionality is implemented in MainWindow::_mSlotSearchText()

      Run the app and write 'QFrame' in the search field. TreeItem is collapsed but the correct row is not highlighted

      Note: It works when entering a search text from the top row or first column ("widgets", "General").

      For reference, qtbug73864_stditm.zip is an implementation based on QStandardItemModel (which again acts differently).

      Attachments

        1. AbstractMatch.zip
          12 kB
        2. qtbug73864_stditm.zip
          5 kB
        3. qtbug73864.zip
          10 kB
        For Gerrit Dashboard: QTBUG-73864
        # Subject Branch Project Status CR V

        Activity

          People

            kleint Friedemann Kleint
            pekarjal Pekka Karjalainen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes