how can i get sortOrder of QTreeWidget?
-
how can i get sortOrder of QTreeWidget?
is it depends on the sortColumn?
thank you very much! -
This post is deleted! -
if there is no way to get the sortOrder directly,
can i add a memeber which record the order manually...but how can i set this new member when i click on the Header to sort the items? -
i saw a API sortOrder, but it's private......
-
solved
class MyTreeWidget : public QTreeWidget
{
Q_OBJECTpublic:
MyTreeWidget(QWidget* parent = 0)
: QTreeWidget(parent)
{
// disable built-in sorting
setSortingEnabled(false);// use our own sorting method instead
header()->setSortIndicatorShown(true);
header()->setClickable(true);
connect(header(), SIGNAL(sectionClicked(int)), this, SLOT(customSortByColumn(int)));
customSortByColumn(header()->sortIndicatorSection());
}public slots:
void customSortByColumn(int column)
{
// here you can get the order
Qt::SortOrder order = header()->sortIndicatorOrder();// and sort the items
sortItems(column, order);// to get more control over actual sorting of items,
// reimplement QTreeWidgetItem::operator<()
}
};