How to get some value which specifies which column the data is sorted by (and whether it's ascending or descending) in QTableWidget
? I couldn't find anything in the documentation about it, only about sorting programmatically.
You can access that through the table header. Basically in Qt everything that is related to whole columns is accesses through the horizontal header of the table, and everything related to whole rows is accessed though the vertical headers. This includes default sizes, stretches, or, in your case, the sort properties.
SortIndicatorOrder()
function returns the sort order as Qt::SortOrder
enum wihch can be either Qt::AscendingOrder
a.k.a. 0
, or Qt::DescendingOrder
a.k.a. 1
. You can use it ilke this:
ui.yourTable->horizontalHeader()->sortIndicatorOrder();
sortIndicatorSection()
function returns the column by wihch data is sorted. Column numbers start with 0. You can call it like this:
ui.yourTable->horizontalHeader()->sortIndicatorSection();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With