Maybe what I am trying to do is not possible?
Declared the following in a function:

Qt Code:
  1. QSqlTableModel *model = new QSqlTableModel(this, logdb);
  2. QTableView *view = new QTableView();
  3. QHeaderView *header = new QHeaderView(Qt::Horizontal);
To copy to clipboard, switch view to plain text mode 

If it any of these are referenced within the function after they are created, all is well.
If you try to reference say the header, in a different function, maybe to save it - crash.
No doubt null pointer exception, but why? Shouldn't the header still exist?

It seems the design of QSqlTableModel prevents declaring it as a class member since you can't assign a different database to it later. So it would only be good for one database.

Am I missing something here? Or should I try a completely different approach?