1

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 ?

Community
  • 1
  • 1
Simon
  • 1,522
  • 2
  • 12
  • 24

1 Answers1

4

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();
George Hilliard
  • 15,402
  • 9
  • 58
  • 96