Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 9th, 2012  |  syntax: C++  |  size: 0.96 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. void Calculator::sommatoria(){ //sommatoria del valore inserito per i che va da 0....operando
  2.     Button *clickedButton = qobject_cast<Button *>(sender());
  3.     QString clickedoperator = clickedButton->text();
  4.     //when this operator is clicked, it is not executed immediately.I Save current operation as a possible pending operation
  5.  
  6.     double operand = display->text().toDouble(); // saving operand from display
  7.     if (!pendingaddictionoperator.isEmpty()) {  //if there are pending operators
  8.           if (!calculate(operand,pendingaddictionoperator)) { //if some circumstances abort
  9.             abortOperation();
  10.             return;
  11.           }
  12.            display->setText(QString::number(totalsum)); //else display new totalsum (calcolated with "calculate")
  13.     } else {  //if there are NO pending operators
  14.         totalsum = operand;
  15.     }
  16.  
  17.     pendingaddictionoperator = clickedoperator;
  18.     waitingForOperand = true;
  19. }