【问题标题】:How does Qt's QHeaderView::saveState() and QHeaderView::restoreState() work?Qt 的 QHeaderView::saveState() 和 QHeaderView::restoreState() 是如何工作的?
【发布时间】:2016-12-22 05:14:47
【问题描述】:

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

我已经阅读了documentationthis example,但都没有说明具体保存了什么。我也尝试在source code中查找,但没有找到实现。

我需要了解下面做了什么的原因是我正在重构已经保存列顺序和隐藏列首选项的代码。我想确保 QHeaderView::saveState() 和 QHeaderView::restoreState() 做同样的事情。谢谢。

【问题讨论】:

标签: c++ qt


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-30
    • 1970-01-01
    • 1970-01-01
    • 2018-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多