Click here to Skip to main content
15,886,661 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys
I'm New In QT And C++.
I Design Calculator Using C++ And QT
I Using QLcdNumber In QT And I Want To Know How I Can Add Number To Outher Every Click On Button.
Ex:
I Press Button 1
And Then I Press Button 2
Then QLcdNumber = 12
I Try To Use The + But It Calculate Them.

This My Code In Button 1 ( Event Clicked )

C++
const int one = 1;
  int newvalue;

  if (ui->viewlcdnumber->value() == 0)
  {
      ui->viewlcdnumber->display(one);
  }
  else
  {
      newvalue = one + ui->viewlcdnumber->value();
      ui->viewlcdnumber->display(newvalue);
  }
Posted

1 solution

Can you simple multiply the old value *10?
C++
newvalue = 10 * ui->viewlcdnumber->value() + 1 ;
ui->viewlcdnumber->display(newvalue);
 
Share this answer
 
v2
Comments
Mohibur Rashid 17-Jan-13 21:12pm    
string processing would be much simpler

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900