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:
private:
class QSqlTableModel;
class QTableView;
private:
QSqlTableModel *model;
QTableView *view;
To copy to clipboard, switch view to plain text mode
And part of the cpp:
model->setTable("log");
model->select();
view->setModel(model);
view->setMinimumSize(1200,100);
view->move(35,80);
view->setSortingEnabled(TRUE);
header->setMovable(TRUE);
view->show();
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();
To copy to clipboard, switch view to plain text mode
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'");
}
checkPrefs();
void MainWindow::checkPrefs() {
view->setWindowTitle("My Log");
MainWindow::model->setFilter("call = 'k0zav'");
}
To copy to clipboard, switch view to plain text mode
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?
Bookmarks