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

Got an assert error "last < columnCount(parent)" when hidding the last column by using QSortFilterProxyModel,TreeModel(QAbstractItemModdel) and TreeView together in QML.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.7.2, 6.7.3, Some future release
    • None
    • Window 10
      Visual studio 2022
      Qt6.7.2
    • Windows

    Description

      Hello,I got an assert error "last < columnCount(parent)" when hiding the last column by overriding the function filterAcceptColumn of QSortFilterProxyModel.

      The impl of filterAcceptColumn below(Assuming there are two columns):

      bool MyProxyModel::filterAcceptsColumn(int SourceColumn, const QModelIndex& SourceParent) const

      {     return SourceColumn != 1; }

      This assert is reported in the function beginRemoveColumns of QSortFilterProxyModel.I checked my source tree model, and I am sure it is correct. This problem only appears when there is a parent-child relationship of data structure and column count is greater than 1.When using my source tree model with table structure data, it works right.

      Even though I used the tree model of official sample program ("editabletreemodel") in TreeView, proxy model still appears assert error "last < columnCount(parent)" when hiding the last column. It works right in QTreeView but TreeView.

       I thought this bug is most likely comes from the TreeView.

      Thanks for watching.

       

      Attachments

        1. image-2024-11-05-14-23-27-511.png
          image-2024-11-05-14-23-27-511.png
          33 kB
        2. myproxymodel.cpp
          0.6 kB
        3. myproxymodel.h
          0.5 kB
        4. treeitem.cpp
          3 kB
        5. treeitem.h
          0.9 kB
        6. treemodel.cpp
          7 kB
        7. treemodel.h
          2 kB
        8. TreeView.qml
          6 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            dfaure_kdab David Faure
            auroralime Ricarsen Lee
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes