Don't rely on the Qt version when reading a QHeaderView state stream

Since the datastream version is not set in previous versions of Qt when
streaming the state of the QHeaderView then we cannot rely on this when
adding new data to the state. Therefore we check if we read past the
end before assigning to the new variable.

Change-Id: I7128ffc91e47f9c8797cfa24d206a789d2814908
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>