Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QAbstractItemModel sort function doesn't update tree view expanded / collapse elements
hershey last edited by
I'm having a problem with the sorting a tree view. I want to overwrite QAbstractItemModel sort function. I have been successfully able to sort how I would like, but the Collapsed and Expanded elements dont' get updated. So if the first element is expanded then it will always stay expanded no matter how I sort it.
I want to be able to expand an element then be able to sort it and keep it expanded. I have searched many places online and I can't find any examples of this sort function should work.
Any help or hints would be appreciated.
Hi and welcome to devnet,
When it comes to sorting and/or filtering, the way recommended is "QSortFilterProxyModel":http://qt-project.org/doc/qt-4.8/qsortfilterproxymodel.html
Hope it helps