Hey guys,
I've been programming in QT for a few months here and there, but I seem to have run in to an issue.
I'm writing a program that reads from an SQL database (and displays the data in a QTableView when the user clicks on a button). The only thing I need help with is that the windows don't close automatically when I close the main program.
I'm using this function template to display my windows:
void server :: showCandidates()
{
testQuery->setQuery("SELECT * from candidates");
test->setModel(testQuery);
test->setWindowTitle("Candidates");
test->show();
}
void server :: showCandidates()
{
QSqlQueryModel *testQuery = new QSqlQueryModel;
testQuery->setQuery("SELECT * from candidates");
QTableView *test = new QTableView;
test->setModel(testQuery);
test->setWindowTitle("Candidates");
test->show();
}
To copy to clipboard, switch view to plain text mode
and I just trigger that with a signal, like
connect(ui->candidatesButton, SIGNAL(clicked()), this, SLOT(showCandidates()));
connect(ui->candidatesButton, SIGNAL(clicked()), this, SLOT(showCandidates()));
To copy to clipboard, switch view to plain text mode
I tried to tie the QTableView to the main window (as the parent) but that was giving me trouble (it wouldn't create a new window, it would just pop the table view in the main window and overlap with the GUI).
Any help would be much appreciated, I'm not the smartest with programming so please don't make answers too complicated.
Thanks in advance!
Bookmarks