小改
This commit is contained in:
parent
6acdb21e2d
commit
61d50f2668
1 changed files with 9 additions and 3 deletions
|
@ -22,8 +22,8 @@ void MainWindow::abortOperation() {
|
||||||
result = 0.0;
|
result = 0.0;
|
||||||
pendingOperator.clear();
|
pendingOperator.clear();
|
||||||
ui->lineEdit->setText("0");
|
ui->lineEdit->setText("0");
|
||||||
waitForOperand = true;
|
isFinished = false;
|
||||||
QMessageBox::warning(this, "运算错误", "除数不能为零");
|
QMessageBox::warning(this, "运算错误", "算式不合法");
|
||||||
}
|
}
|
||||||
|
|
||||||
//数字被点击
|
//数字被点击
|
||||||
|
@ -55,7 +55,13 @@ void MainWindow::on_clearAllBtn_clicked() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_equalBtn_clicked() {
|
void MainWindow::on_equalBtn_clicked() {
|
||||||
result = cal(displayText.toStdString());
|
try {
|
||||||
|
result = cal(displayText.toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (...) {
|
||||||
|
abortOperation();
|
||||||
|
}
|
||||||
isFinished = 1;
|
isFinished = 1;
|
||||||
ui->lineEdit->setText(QString::number(result));
|
ui->lineEdit->setText(QString::number(result));
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue