Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to sort TreeView Items using QSortFilterProxyModel based on a Combobox selection

How to sort TreeView Items using QSortFilterProxyModel based on a Combobox selection

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 456 Views
  • 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.
  • E Offline
    E Offline
    ehsanen
    wrote on last edited by ehsanen
    #1

    I have a TreeView in my app. I limit the displayed rows using a class which is inherited from QSortFilterProxyModel. I also need to sort the items in the TreeView based on selectedIndex of a combobox.
    What I did so far is:

    • When the selected Index of the combo box changes, I will call a function in the class inherited from QSortFilterProxyModel which calls sort(0) function.

    • In the class inherited from QSortFilterProxyModel, I have overridden the lessThan function and implemented my logic based on the current selection in the ComboBox

    The problem is, the sorting does not always happen. When I run the app, and I choose an item in the combobox, the tree items get sorted correctly. But if I select another item in the combobox, the Tree will not get updated. The lessThan function will get called, though!

    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