QAbstractItemModel sort function doesn't update tree view expanded / collapse elements

  • Hello,

    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.

    Thank you

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    When it comes to sorting and/or filtering, the way recommended is "QSortFilterProxyModel":

    Hope it helps

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.