willief
7th April 2011, 19:00
Hi, I'm having some trouble trying to show a QTableView window with a push button.
When I have the following in my main.cpp, it opens both the main window and the table window:
int main(int argc, char *argv[])
{
QApplication a(argc,argv);
//some splash screen stuff
dcsTS w;
w.show();
//more splash screen stuff
QTableView tableView;
RegModel RegModel(0);
tableView.setModel(&RegModel);
tableView.show();
return a.exec();
Now, I created a function that in my main window file that activates a pushbutton, that when clicked should run those same four lines of code:
void dcsTS::showTable(){
QTableView tableView;
RegModel RegModel(0);
tableView.setModel(&RegModel);
tableView.show();
}
instead of having it in the main file. I was hoping this would magically make the table pop up when i pressed the button, however this is not the case, any ideas?
When I have the following in my main.cpp, it opens both the main window and the table window:
int main(int argc, char *argv[])
{
QApplication a(argc,argv);
//some splash screen stuff
dcsTS w;
w.show();
//more splash screen stuff
QTableView tableView;
RegModel RegModel(0);
tableView.setModel(&RegModel);
tableView.show();
return a.exec();
Now, I created a function that in my main window file that activates a pushbutton, that when clicked should run those same four lines of code:
void dcsTS::showTable(){
QTableView tableView;
RegModel RegModel(0);
tableView.setModel(&RegModel);
tableView.show();
}
instead of having it in the main file. I was hoping this would magically make the table pop up when i pressed the button, however this is not the case, any ideas?