[SOLVED] Persisiting QTreeView's header between model updates

I'm migrating my project from QTreeWidget to QtreeView. With a widget there's no problem with the header - it lives as long as the widget does, so I just save its geometry and state to settings when quitting app and restoring when the app is starting.

With QTreeView, however, it seems that I can only set header by doing model->setHorizontalHeaderLabels, and it has to be done again after model()->clear(), i. e. after every model update. So I'd have to recreate header view and store / restore its state and geometry every time. Is there a better way? Am I missing something?