I am using a QMessageBox
to warn the user if he pressed Delete button by mistake. when the user press Ok button in the QMessageBox
, a function is called to delete a row from QTableView
(that is connected to a database). after the deletion, the QTableView should be refreshed and the new data (without the deleted row) should be shown.
now, when the user hits Delete button
, the warning QMessageBox
appears. then, when he presses Ok, the row is deleted from the QTableView
. at this point I expect the QMessageBox
to disappear, and the new refreshed version of the QTableView
to be shown which is not happening !!. instead the QMessageBox
appears again and the refresh has to be manually done (as I am just starting the application ) .. why is this happening ?
here is my code:
QMessageBox msg;
msg.setIcon(QMessageBox::Warning);
msg.setText("Delete");
msg.setInformativeText("continue ?");
msg.setDetailedText("Delete permanently");
msg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msg.setDefaultButton(QMessageBox::Cancel);
int ret = msg.exec();
if(ret == 1024){
msg.Close;
deleteDataBaseRecord(); // connect to server and delete DB data which is then show the QTableView again
}
else {
msg.Close;
}