I am working on a simple calculator app in Qt. I want to display an error message when the user tries to divide by zero. I have tried the code below but the output just stays as 0.
if(dblDisplayVal == 0.0){
QString error = "Can't divide by zero!";
ui->display->insert(error);
}
else{
result = calcVal / dblDisplayVal;
divTrigger = false;
}
Any idea on how I can solve this issue?
CodePudding user response: