PySide6, QTreeView, sort, make initial order be ascending

32 views Asked by At

I created a subclass of QTreeView (to use context menu). I called self.setSortingEnabled(True); in the def __init__(self, parent=None): to make it sort the tree to click column headers.

The problem is that when my app is first started, it gets sorted by the first column's descending order. the first column is name, so the tree gets sorted by names like "Zeus" to "Alexander".

enter image description here

I think it would be more natural that it is first sorted by ascending order, like "Alexander" to "Zeus". How to change the initial order (of course, the column header's visual indicator should match the order).

0

There are 0 answers