The final part of our CRUD operations is deleting an existing client. Let’s trigger this via a new button on EditClientView. We’ll begin by adding the slot that will be called when the button is pressed to CommandController:
void CommandController::onEditClientDeleteExecuted() { qDebug() << "You executed the Delete command!"; implementation->databaseController->deleteRow(implementation->selectedClient->key(), implementation->selectedClient->id()); implementation->selectedClient = nullptr; qDebug() << "Client deleted."; implementation->clientSearch->search(); }
This follows the same pattern as the other slots, except this time we also clear the selectedClient property as although the client instance still exists in application ...