Disable sorting in QTreeView



  • Hello!!

    I am working with QTreeView and I have a little issue.

    I show different configurations in a QTreeView so, for example, I insert 3 rows with this ID's and order:

    row 0 --> id: 9
    row 1 --> id: 4
    row 2 --> id: 7

    When I change the current index of a QComboBox, I load its information in the tableview and, when I reload this data again, the rows have this order:

    row 0 --> id: 4
    row 1 --> id: 7
    row 2 --> id: 9

    The rows sorted automatically.

    How can I disable it?

    Thank you very much!!!



  • Hi ivanicy,

    When you change the index of the QComboBox do you use the setSortingEnabled() function that is part of QTreeView and if so do you set it to true?

    Also could you provide screenshots of the before and after, i am quite new to this so a visual aid might help get to the root cause of this.

    Thanks



  • The answer is add a QSortFilterProxyModel in-between. the question is where.

    @ivanicy said in Disable sorting in QTreeView:

    When I change the current index of a QComboBox, I load its information in the tableview and, when I reload this data again

    What does this mean exactly?


Log in to reply
 

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