Differentiate real time data



  • Hi friends i have a simple problem. I have time information (Count Down Time) comming from the socket every one second. I want to take a difference of the current value from the previous value of seconds. eg if current value of second is 10 and previous was 9 then i want to subtract 10-9. How can i do it programatically. Please suggest. Thank u all in advance.


  • Lifetime Qt Champion

    Hi,

    Keep a copy of the last value received, subtract the new and store it in place of the last one.

    There isn't much more than that

    Hope it helps



  • [quote author="SGaist" date="1390251464"]Hi,

    Keep a copy of the last value received, subtract the new and store it in place of the last one.

    There isn't much more than that

    Hope it helps[/quote]

    Hi SGaist now i am able to do .Actually i was not knowing how to keep the last one. But now i am able to do with static variable. Thank u


  • Lifetime Qt Champion

    If you are using static variables for that you are probably doing it wrong.

    You don't need them for this kind of problem



  • [quote author="SGaist" date="1390307986"]If you are using static variables for that you are probably doing it wrong.

    You don't need them for this kind of problem[/quote]

    Hi SGaist i have implemented using static variable only and it is working also.
    I am putting the last value in a static variable every time after taking the difference of current and last value. I have implemented it using timer. On every timeout of timer i read the current value and put the current value into ststic variable lastvalue. In this way my code was solving my purpose.

    If u can suggets a better and accurate solution you are most welcome and plz explain how to do that??


  • Lifetime Qt Champion

    I didn't say it would not work, but you are using the wrong tool.

    A class member is better suited for that


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.