我想保存tableview的列顺序以及是否显示每列。看起来QHeaderView::saveState()和QHeaderView::restoreState()可以满足我的要求。

我已经阅读了documentationthis example,但是都没有说保存的内容。我也尝试在source code中查找,但是没有找到实现。

我需要了解底层操作的原因是,我正在重构已经保存了列顺序和隐藏的列首选项的代码。我想确保QHeaderView::saveState()和QHeaderView::restoreState()完全相同。谢谢。

最佳答案

herehere中保存以下数据:

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

关于c++ - Qt的QHeaderView::saveState()和QHeaderView::restoreState()如何工作?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28090585/

10-11 22:44
查看更多