You can access this through the table header. Basically, in Qt, everything related to whole columns is access through the horizontal heading of the table, and everything related to whole rows is available, albeit with vertical headers. This includes default sizes, stretching, or, in your case, sorting properties.
Function
SortIndicatorOrder() returns the sort order as Qt::SortOrder enum wihch can be either Qt::AscendingOrder aka 0 or Qt::DescendingOrder aka 1 . You can use it ilke:
ui.yourTable->horizontalHeader()->sortIndicatorOrder();
Function
sortIndicatorSection() returns a column according to wihch data. Column numbers start at 0. You can call it this way:
ui.yourTable->horizontalHeader()->sortIndicatorSection();
source share