Ok, I'm stumped.
When I call openLog from the mainwindow menu, the existing model and view are deleted and replaced by the selected new ones. Works perfectly.
But, when I call openLog from a dialog via the mainwindow menu, to create and open a new database, it crashes when it tries to delete the current model and view.
void MainWindow
::openLog(QString logName
) { delete model; // existing
delete view; // existing
db.setDatabaseName(logName + ".log.sqlite");
db.open();
model->setTable("log");
//etc ...
void MainWindow::openLog(QString logName) {
delete model; // existing
delete view; // existing
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(logName + ".log.sqlite");
db.open();
model = new QSqlTableModel();
view = new QTableView();
model->setTable("log");
//etc ...
To copy to clipboard, switch view to plain text mode
But... this crashes unless I comment out the delete model and delete view lines.
void NewLog::createLog() {
QString log = m_ui
->nlName
->text
();
MainWindow mw;
mw.openLog(log);
NewLog::close();
}
void NewLog::createLog() {
QString log = m_ui->nlName->text();
MainWindow mw;
mw.openLog(log);
NewLog::close();
}
To copy to clipboard, switch view to plain text mode
Bookmarks