replace model correctly

This commit is contained in:
Martin Brodbeck 2018-07-27 09:55:47 +02:00
parent 17c65a50ea
commit 2003530587

View file

@ -49,7 +49,8 @@ void MainWindow::on_actionEditSeller_triggered()
auto dialog = std::make_unique<SellerDialog>(this); auto dialog = std::make_unique<SellerDialog>(this);
int retCode = dialog->exec(); int retCode = dialog->exec();
delete ui_.salesView->model(); auto oldModel = ui_.salesView->model();
ui_.salesView->setModel(nullptr);
if (retCode == QDialog::Accepted) { if (retCode == QDialog::Accepted) {
marketplace_->sortSellers(); marketplace_->sortSellers();
@ -63,6 +64,7 @@ void MainWindow::on_actionEditSeller_triggered()
} }
ui_.salesView->setModel(new SaleModel(getMarketplace(), ui_.salesView)); ui_.salesView->setModel(new SaleModel(getMarketplace(), ui_.salesView));
delete oldModel;
ui_.salesView->setColumnHidden(2, true); ui_.salesView->setColumnHidden(2, true);
ui_.salesView->resizeColumnToContents(0); ui_.salesView->resizeColumnToContents(0);
connect(static_cast<BasketModel*>(ui_.basketView->model()), &BasketModel::basketDataChanged, connect(static_cast<BasketModel*>(ui_.basketView->model()), &BasketModel::basketDataChanged,