Issue
How can I re-arrange my hierarchy in a proxy model?
Even though I am overriding my rowCount method in the proxy model, it seems to only ever call it once (for the root item). After that it never gets called again.
I found that after it calls the mapToSource function to map the indexes, its the rowCount method in my main model that gets called instead of the one in the proxy model. If I change my hierarchy in the main model to match my proxy it will then draw the children in the proxy as well.
Makes me wonder if it is even possible to manipulate the hierarchy in the proxy (other than just flattening it).
Solution
From what I can tell, the rowCount method in QAbstractProxyModel is bugged in PySide . I've been banging my head against the wall for a long time over this one. Haven't been able to figure out whats going on.
I just implemented the hasChildren method because I remembered finding something mentioned about it being an optimization method incase rowCount is heavy and it just force flags your item as needing a dropdown icon next to it. Anyways, tested it (actually just direct copied over my rowCount method) and I got my dropdown icon!
Clicked the dropdown, and sure enough I got my children nodes. If I comment out the hasChildren method, and make no other changes, I am back to it not working anymore (even though rowCount is implemented and working correctly).
Answered By - Mathieson
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.