PDA

View Full Version : QHeaderView



waynew
25th December 2009, 17:24
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?

nateriver
25th December 2009, 17:48
Well, you can store it as a class member, or pass it to another function as an argument.

header = new QHeaderView(Horizontal, QWidget *parent = 0);
This won't compile unless you have member or local variable "header". Furthermore, "Horizontal" is declared in "Qt" namespace, thus should be accessed via "Qt::Horizontal" (without the quotes), and the second argument to the constructor is.. hm.. well that way it can only be used in constructor declaration (it actually means optional argument with default value equal to 0), so it's definately syntax error.

waynew
25th December 2009, 20:42
Thanks - I get so focused on what I am trying to make the code do that I forget the basics. Compiles fine.

Now if I can just get the saveState() QByteArray to save properly in the database all will be well.