Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QAbstractItemModel + QSortFilterProxyModel leads to random item expansion
Forum Updated to NodeBB v4.3 + New Features

QAbstractItemModel + QSortFilterProxyModel leads to random item expansion

Scheduled Pinned Locked Moved Unsolved Qt for Python
6 Posts 2 Posters 441 Views 2 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.
  • S Offline
    S Offline
    salvaom
    wrote on last edited by
    #1

    Video repro: https://imgur.com/a/ahBSuhH
    Repro code: https://gist.github.com/salvaom/c5531458251d77d753bfda57e3895756

    The issue is quite obvious, when using a custom QAbstractItemModel and a QSortFilterProxyModel items are expanded randomly when selecting items. I've been experiencing this issue since PySide(1), in Windows and Centos7. I have a feeling that it's something I'm doing wrong since I believe this case is common enough for others to have attempted it.

    This does not happen without the QSortFilterProxyModel and at this point I'm lost on why could this happen.

    Does somebody know what I'm doing wrong? Is it perhaps a bug in Qt?

    Thanks.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Sorry I do not have a machine at hand but what do you get you enable recursive filtering ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        salvaom
        wrote on last edited by
        #3

        Thanks for the reply @SGaist, yes it keeps happening with recursive filtering. Just as a reference, I'm testing with Python 2 and 3, and PySide(1), 2 and 6 in Windows and they all seem to have the same result, having in consideration that PySide(1) does not have the setRecursiveFilteringEnabled method.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          salvaom
          wrote on last edited by salvaom
          #4

          This is odd... After further testing I've seen that it also happens with QStandardItemModel but it only happens for models with a fetchMore

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Still with the proxy model ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • S Offline
              S Offline
              salvaom
              wrote on last edited by
              #6

              Yes, any QAbstractItemModel based model with a fetchMore and a QSortFilterProxyModel seems to be the combination.

              I've been trying to debug it with little success. I've seen that it's no based on the selection but on the cursor, I've tested with expanding the items avoiding selection and it works fine, it's when the current cursor is moved there (QTreeView.moveCursor), but again, only if the conditions above are met.

              1 Reply Last reply
              0

              • Login

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