
Untitled
By: a guest on
Aug 9th, 2012 | syntax:
C++ | size: 0.96 KB | hits: 10 | expires: Never
void Calculator::sommatoria(){ //sommatoria del valore inserito per i che va da 0....operando
Button *clickedButton = qobject_cast<Button *>(sender());
QString clickedoperator = clickedButton->text();
//when this operator is clicked, it is not executed immediately.I Save current operation as a possible pending operation
double operand = display->text().toDouble(); // saving operand from display
if (!pendingaddictionoperator.isEmpty()) { //if there are pending operators
if (!calculate(operand,pendingaddictionoperator)) { //if some circumstances abort
abortOperation();
return;
}
display->setText(QString::number(totalsum)); //else display new totalsum (calcolated with "calculate")
} else { //if there are NO pending operators
totalsum = operand;
}
pendingaddictionoperator = clickedoperator;
waitingForOperand = true;
}