I did it once like this for a static QTreeWidget:
Of course, it doesn't apply in your situation Patrik because you're using a model, not QTreeWidget. But perhaps it turns out to be useful for someone who later searches for a solution on the same subject.Qt Code:
void saveTreeState() { QVariantList states; while (*it) { states += (*it)->isExpanded(); ++it; } QSettings settings; settings.setValue("states", states); } void restoreTreeState() { QSettings settings; QVariantList states = settings.value("states").toList(); while (*it && !states.isEmpty()) { (*it)->setExpanded(states.takeFirst().toBool()); ++it; } }To copy to clipboard, switch view to plain text mode
Bookmarks