PDA

View Full Version : Total time in QTimer



martisho
11th November 2009, 15:06
Hi all,

i am using QTimer, what i want to do is to have a total time, for example 10 minutes and in these 10 minutes, do something every 5 seconds. I know how to put the interval os 5 seconds, but i don´t know how to control that QTimer lasts 10 minutes, and after 10 minutes its stop.

And also how can i store in which interval i am, because what i want to store is the value of a variable in each interval, so i need the interval, and i don´t know how to get it

Thank very much.

yogeshgokul
11th November 2009, 15:15
Hi all,

i am using QTimer, what i want to do is to have a total time, for example 10 minutes and in these 10 minutes, do something every 5 seconds. I know how to put the interval os 5 seconds, but i don´t know how to control that QTimer lasts 10 minutes, and after 10 minutes its stop.

And also how can i store in which interval i am, because what i want to store is the value of a variable in each interval, so i need the interval, and i don´t know how to get it

Thank very much.
You can use 2 QTimer instances. One will be responsible for invoking in each 5 seconds and another will stop first after 10 mins.
Use singleShot for second timer.

Lykurg
11th November 2009, 15:23
Use a QTimeLine:

// Construct a 1-second timeline with a frame range of 0 - 100
QTimeLine *timeLine = new QTimeLine(1000, this);
timeLine->setFrameRange(0, 100);
connect(timeLine, SIGNAL(frameChanged(int)), progressBar, SLOT(setValue(int)));

martisho
11th November 2009, 15:24
Ok, thanks!

And how can i store in wich interval i am, because what i want to store is the value of a variable in each interval, so i need the interval, and i don´t know how to get it.

Lykurg
14th November 2009, 09:24
And how can i store in wich interval i am

??? the frameChanged parameter is your interval! Read the docs about that.