Important: Please read the Qt Code of Conduct -

QTree model architecture

  • Hi all,

    I have a view/model application using QTreeView and a proxy (all code in PySide/Cython/numpy).
    I use to sort my tree (depth up to 7) using my own function but it was quite difficult to propagate modifications and I think, at the end, the application was in an inconsistent state (probably bad indexes). Then I changed to use the proxy. It looks like the indexes are much better now but I still have some architecture concerns as the sort is not called when I modify the tree, I need a piece of advice:

    • The source model has a setData which allows a node name to be changed, then the sort has to be performed again
    • But the setData is in the source model and has no knowledge of the proxy model, I cannot propagate any dataChanged or rowsMoved

    Do the sourceModel has to re-emit its own messages to the proxy (rowsMoved, dataChanged...) ?
    How can I ask the sourceModel to trigger the proxy model so that the node name change is taken into account ?
    Should I move the setData into the proxy model ?

    see source :

    line780 into

    warning: lines 798 to 801 cannot work because instead of self. I should use the proxy model... it has been committed for the purpose of this forum.

Log in to reply