Hi,
I need to do a countdown of a time (i.e. 3':40''). I must to code myself (3':00''...2':59''....)it or are there any istructions simplify my life?
Thanks?
Hi,
I need to do a countdown of a time (i.e. 3':40''). I must to code myself (3':00''...2':59''....)it or are there any istructions simplify my life?
Thanks?
Regards
Is there a need for using time.h? Why not use timer events offered by Qt?
See QObject::startTimer(int interval)
I Need not use QT for this.........any suggest?
Regards
There are surely system timers which you can use. For example under Linux you can use setitimer(). I'm sure Windows has something simmilar. If not, you can always spawn a separate thread and put it to sleep() for the desired amount of time and after it wakes up, it can somehow signal the main thread that the time has passed.
clock_t ticks; // Time in clock ticks
// If Windows ...
ticks = clock();
// else ...
struct tms tmpBuffer;
ticks = times(&tmpBuffer);
Depends on the accuracy you need, but UN*X times provide easy calculation. Use the time() function to get the current time. Then convert the supplied time to seconds since January 1st 1970. Subtract the two, and you have your countdown in seconds. Converting to minutes and hours should be trivial.
I don't need take current time. i need to have a variable that I set 'a time' (eg 4':30''). Then begin countdown of this.....I'm in widows....
Regards
Convert it to seconds and store them as integer. If you don't want to use QTime, you can write your own class --- it should take only a couple of minutes to implement it.Originally Posted by mickey
Bookmarks