Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ QT
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 )
 
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 17-Jan-13 9:25am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Can you simple multiply the old value *10?
newvalue = 10 * ui->viewlcdnumber->value() + 1 ;
ui->viewlcdnumber->display(newvalue);
 
  Permalink  
v2
Comments
Mohibur Rashid at 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)



Advertise | Privacy | Mobile
Web04 | 2.8.150305.1 | Last Updated 17 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100