PDA

View Full Version : on Button Click decrement the data



anh5kor
26th February 2015, 13:57
Hello ,

In code I am trying to implement, that on every button click my data should be reduce.


constructor()
{
connect(ui->pb_uss2ecu_readleft,SIGNAL(clicked()),this,SLOT(Re ad_File_uss2ecuLeft()));
}
somefunction()
{
uss2ecu_count = 144;
}
Read_File_uss2ecuLeft()
{ qDebug()<<"uss2ecu_count_first"<<uss2ecu_count;
uss2ecu_count--;
qDebug()<<"uss2ecu_count_last"<<uss2ecu_count;
}


My output is
First Click
uss2ecu_count_first 144
uss2ecu_count_last 143
second Click
uss2ecu_count_first 189
uss2ecu_count_last 188

That is on every time click it is increasing the data rather than taking old data
My Output should be
First Click
uss2ecu_count_first 144
uss2ecu_count_last 143
second Click
uss2ecu_count_first 143
uss2ecu_count_last 142

d_stranz
26th February 2015, 16:36
You haven't posted real code. You've posted some pseudocode that won't even compile, much less run. How do you expect to get help with a problem when you post something that isn't the problem at all? How can we tell what might be going wrong when all you give us is a few scraps of pseudocode?

ChrisW67
27th February 2015, 20:27
Programming is not magic. If the number is changing then something in your program is changing it. Look at all the places in your real code where you assign a value to uss2ecu_count... One of these must be involved. Then work out how you program gets there.