PDA

View Full Version : Time measure beetwen events



felo188
18th August 2011, 12:56
Hi.
I would like to measure time beetwen two, or more, events. I wanted somethink like this:
- enter on button1 (IRButton1)--> start time
- enter on button2 (RFidButton) --> stop time
- do somethink depending on difference start and stop time.
In event filter timer starts:

...
if ((object == IRButton1) && ev->type() == QEvent::Enter)
{
...
timer1->start(1000);
...
}

And stops.


if ((object == RFidButton) && ev->type() == QEvent::Enter)
{
...
timer1->stop();
...
}
...
I call also:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
...
connect(timer1,SIGNAL(timeout()),this,SLOT(updateR FiD()));
...


I try with
int MainWindow::updateRFiD()
{
return 1;
}
...
if (updateRFiD()) secs++;

But it doesn't working and now i don't know what do next.

Added after 26 minutes:

I do it in different way i wanted to do :)

Just call QTime::currentTime().second() in both event filter (in button1 and button2) and subtracted them. In that way i get different in seconds.

Lesiok
18th August 2011, 14:18
Read about QElapsedTimer