QTreeWidget multiple sorts
I'm using QTreeWidget with custom sort based on what I found through searching:
- the elements of QTreeWidget are a new class that is a child of QTreeWidgetItem and has its own definition of the method __lt__ (in python, from what I understand in C++ it would be the < method).
It seems to work. However, what I want to do is for the sorting to behave differently depending on whether the sort order of QTreeWidget is normal or reverse. I don't want it to simply reverse the order.
When you set setSortingEnabled to true, the widget title will become clickable and there is an arrow pointing down or up depending on whether the sort order is ascending or descending. What I want to do is for my class to query the QTreeWidget and find out what the direction is, or something similar that will help me. I was unable to find how to do this. Is there a method or an attribute for this?
I use PyQt4 if that is important.
I figured it out, that information is the header of the QTreeWidget. So, the code to extract this value from within a QTreeWidgetItem is:
and this you can check for being equal to Qt.DescendingOrder (or Qt.AscendingOrder if you prefer).