void MainWindow::on_pushButton_clicked()
{
Model *model = new Model;
ui->tableView->setModel(model);
}
Where can I delete model object, please help.
CodePudding user response:
You can just do
Model *model = new Model(this);
This will set MainWindow
as parent of the Model
. MainWindow will delete the object when it gets destroyed itself.
Read more https://doc.qt.io/qt-5/objecttrees.html