Simon
Simon

Reputation: 1590

Qt QTreeWidget save columns order

How can I save the QTreeWidget column order ?

I know it can be done via QTreeView from this post

HowTo make restoreState() and saveState() work correctlly to QTableView class?

but I don't see how I can do it with QTreeWidget.

Any suggestions ?

Upvotes: 1

Views: 871

Answers (1)

George Hilliard
George Hilliard

Reputation: 15952

A QTreeWidget is a QTreeView (it inherits it), so any function you can call on a QTreeView, you can also call on a QTreeWidget.

You can get the (only) header from a QTreeView (and therefore also from a QTreeWidget) using its QTreeView::header() member function. For example:

QTreeWidget *treeWidget = new QTreeWidget(this);
QByteArray saved = treeWidget->header()->saveState();

Upvotes: 4

Related Questions