azalea
azalea

Reputation: 12620

How does Qt's QHeaderView::saveState() and QHeaderView::restoreState() work?

I would like to save tableview's column order and whether each column is shown. It looks like QHeaderView::saveState() and QHeaderView::restoreState() does what I want.

I've read the documentation and this example, but neither says what is saved exactly. I also tried to look up in the source code, but did not find the implementation.

The reason I need to understand what is done underneath is that I am refactoring code that already saves column order and hidden column preferences. I'd like to make sure QHeaderView::saveState() and QHeaderView::restoreState() does exactly the same thing. Thanks.

Upvotes: 3

Views: 1246

Answers (1)

From here and here the following data is saved:

out << int(orientation);
out << int(sortIndicatorOrder);
out << sortIndicatorSection;
out << sortIndicatorShown;
out << visualIndices;
out << logicalIndices;
out << sectionHidden;
out << hiddenSectionSize;
out << length;
out << sectionCount;
out << movableSections;
out << clickableSections;
out << highlightSelected;
out << stretchLastSection;
out << cascadingResizing;
out << stretchSections;
out << contentsSections;
out << defaultSectionSize;
out << minimumSectionSize;
out << int(defaultAlignment);
out << int(globalResizeMode);
for each sectionSpan:
    out << size;
    out << count;
    out << (int)resizeMode

Upvotes: 3

Related Questions