How to reference a QHeaderView from a different function?

When it is declared like this:

QHeaderView *header = view->horizontalHeader();

It works ok, but I can't reference it from another function to save the column positions when the user quits.

When I try to use this:

header = new QHeaderView(Horizontal, QWidget *parent = 0);

It won't compile.

Any ideas as to how I can do this?