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 8: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)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Guruprasad.K.Basavaraju 424
1 Sergey Alexandrovich Kryukov 326
2 Shai Vashdi 318
3 OriginalGriff 265
4 Abhinav S 160
0 Sergey Alexandrovich Kryukov 9,169
1 OriginalGriff 5,290
2 Peter Leow 4,020
3 Maciej Los 3,535
4 Abhinav S 3,263


Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 17 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid