I save the state of QTreeWidget headers to the registry using QSettings, by calling QHeaderView::saveState(). On start up the application reload the state them if it is available.
If the header view state is saved using a Qt4 version of the application and loaded using a Qt5 version of the application or vice-versa, the stored data is read incorrectly and the view misbehaves. E.g., some columns are badly sized, and locked (can't be resized or moved or sorted). The scroll area is miscalculated so scrollbars don't activate when they should so many columns can't even be accessed by the user. Wiping out the relevant information from the registry makes everything work properly again.
The default behavior should be to ignore the byte array and not use it to load the state if it the state version is incompatible.