Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAbstractItemModel sort function doesn't update tree view expanded / collapse elements

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hershey
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved