Qt Code:
  1. void Calculator::calculation(QString &operation, QString &text_display)
  2. {
  3. QString a_string = "", b_string = "", result_string = "", temp_string = "";
  4. double a, b, result;
  5. int position, i, j;
  6.  
  7.  
  8. position = operation.indexOf("*", 0) ;
  9.  
  10. for( i = position - 1; i >= 0 ; i-- )
  11. {
  12. if( operation.at( i ) == '*' || operation.at( i ) == '/' || operation.at( i ) == '+' || operation.at( i ) == '-' )
  13. break;
  14. temp_string = a_string;
  15. a_string = operation.at( i ) + temp_string;
  16. }
  17. ui.display->setText( a_string ); //displays a_string on QLineEdit
  18.  
  19. }
To copy to clipboard, switch view to plain text mode 

Basically this function has to extract a number placed before '*' operator.
When operation = "3+56*35" a_string = "56" and it works correctly. But when operation="56*35" (without any operator before "56" - that is importanat) it multiplies extraced 56 three times and a_string = "565656". I've been thinking for a few hours about that and the problem still exists.

Thanks for help.