waynew
20th December 2009, 00:29
Thanks to the folks who have already helped me along with this, but I am still having a little trouble referencing class members.
Here's the relevant part of the header:
class QSqlTableModel;
class QTableView;
private:
QSqlTableModel *model;
QTableView *view;
And part of the cpp:
model = new QSqlTableModel();
view = new QTableView();
QSqlTableModel *model = new QSqlTableModel();
model->setTable("log");
model->select();
QTableView *view = new QTableView;
view->setModel(model);
view->setMinimumSize(1200,100);
view->move(35,80);
view->setSortingEnabled(TRUE);
QHeaderView *header = view->horizontalHeader();
header->setMovable(TRUE);
view->show();
All of that works fine. Problem comes when I try to use model-> or view->
in a local function. No errors, but no results. Like trying to set the view title or apply a filter to the model. Both of these work fine if the code for them is right after the code shown above, but when in a local function like this, they have no effect.
checkPrefs();
void MainWindow::checkPrefs() {
view->setWindowTitle("My Log");
MainWindow::model->setFilter("call = 'k0zav'");
}
And if I check the model assigned to the view in the checkPrefs code, it comes back empty.
So, what am I doing wrong here?
Here's the relevant part of the header:
class QSqlTableModel;
class QTableView;
private:
QSqlTableModel *model;
QTableView *view;
And part of the cpp:
model = new QSqlTableModel();
view = new QTableView();
QSqlTableModel *model = new QSqlTableModel();
model->setTable("log");
model->select();
QTableView *view = new QTableView;
view->setModel(model);
view->setMinimumSize(1200,100);
view->move(35,80);
view->setSortingEnabled(TRUE);
QHeaderView *header = view->horizontalHeader();
header->setMovable(TRUE);
view->show();
All of that works fine. Problem comes when I try to use model-> or view->
in a local function. No errors, but no results. Like trying to set the view title or apply a filter to the model. Both of these work fine if the code for them is right after the code shown above, but when in a local function like this, they have no effect.
checkPrefs();
void MainWindow::checkPrefs() {
view->setWindowTitle("My Log");
MainWindow::model->setFilter("call = 'k0zav'");
}
And if I check the model assigned to the view in the checkPrefs code, it comes back empty.
So, what am I doing wrong here?