QAbstractItemModel + QSortFilterProxyModel leads to random item expansion
-
Video repro: https://imgur.com/a/ahBSuhH
Repro code: https://gist.github.com/salvaom/c5531458251d77d753bfda57e3895756The issue is quite obvious, when using a custom
QAbstractItemModeland aQSortFilterProxyModelitems 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
QSortFilterProxyModeland 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.
-
Hi and welcome to devnet,
Sorry I do not have a machine at hand but what do you get you enable recursive filtering ?
-
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
setRecursiveFilteringEnabledmethod. -
Still with the proxy model ?
-
Yes, any
QAbstractItemModelbased model with afetchMoreand aQSortFilterProxyModelseems 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.