Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSortFilterProxyModel: problem with columnCount()
Forum Updated to NodeBB v4.3 + New Features

QSortFilterProxyModel: problem with columnCount()

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 499 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • gde23G Offline
    gde23G Offline
    gde23
    wrote on last edited by gde23
    #1

    Hi, I've a QTreeView that shows a QAbstractItemModel through a QSortFilterProxyModel.
    Before adding the proxyModel the model+view worked as intended.
    However since I've added the filter there is the problem, that somehow the columnCount() is not updated correctly in the proxyModel.

    When inserting a column via beginInsertColums() / endInsertColums() (which is done in the sourceModel) the columnCount() of the sourceModel itself shows the correct value.
    However the columnCount() of the QSortFilterProxyModel still shows the old value.
    Do I need to implement any additional functions (except for filterAcceptsRow()) for that to work, or is there something wrong with my model?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Sounds like a bug in Qt to me.

      To force an update, you can call invalidate() on your proxy model, it will trigger a refresh.

      (Z(:^

      1 Reply Last reply
      0
      • gde23G Offline
        gde23G Offline
        gde23
        wrote on last edited by
        #3

        Thanks for the hint with invalidate().
        That somehow solves the problem, however only when I trigger it separately from a button or it is called with delay via

        QTimer::singleShot(2, m_tree_filter, SLOT(invalidate()));
        

        This somehow seems to be a unclean solution though. Any ideas why this could happen.

        Qt5.15.2 / Debian

        sierdzioS 1 Reply Last reply
        0
        • gde23G gde23

          Thanks for the hint with invalidate().
          That somehow solves the problem, however only when I trigger it separately from a button or it is called with delay via

          QTimer::singleShot(2, m_tree_filter, SLOT(invalidate()));
          

          This somehow seems to be a unclean solution though. Any ideas why this could happen.

          Qt5.15.2 / Debian

          sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          @gde23 said in QSortFilterProxyModel: problem with columnCount():

          Qt5.15.2 / Debian

          Using outdated Qt is always a good culprit. Try with 6.4.1 or 5.15.11.

          (Z(:^

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            I'm pretty sure QSFPM is correct and you're doing something wrong. Please provide a minimal, compilable example of your issue.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved