Results 1 to 2 of 2

Thread: Time measure beetwen events

  1. #1
    Join Date
    Jul 2011
    Posts
    19
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Time measure beetwen events

    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:
    Qt Code:
    1. ...
    2. if ((object == IRButton1) && ev->type() == QEvent::Enter)
    3. {
    4. ...
    5. timer1->start(1000);
    6. ...
    7. }
    To copy to clipboard, switch view to plain text mode 
    And stops.
    Qt Code:
    1. if ((object == RFidButton) && ev->type() == QEvent::Enter)
    2. {
    3. ...
    4. timer1->stop();
    5. ...
    6. }
    7. ...
    To copy to clipboard, switch view to plain text mode 
    I call also:
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. ...
    5. connect(timer1,SIGNAL(timeout()),this,SLOT(updateRFiD()));
    6. ...
    To copy to clipboard, switch view to plain text mode 

    I try with
    Qt Code:
    1. int MainWindow::updateRFiD()
    2. {
    3. return 1;
    4. }
    5. ...
    6. if (updateRFiD()) secs++;
    To copy to clipboard, switch view to plain text mode 
    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.
    Last edited by felo188; 18th August 2011 at 12:56.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Time measure beetwen events

    Read about QElapsedTimer

  3. The following user says thank you to Lesiok for this useful post:

    felo188 (19th August 2011)

Similar Threads

  1. Replies: 5
    Last Post: 19th November 2010, 02:25
  2. Replies: 6
    Last Post: 18th August 2010, 12:52
  3. Replies: 2
    Last Post: 26th April 2010, 07:58
  4. check the time of last time keyboard is pressed
    By Aki Tomar in forum General Programming
    Replies: 2
    Last Post: 5th February 2008, 09:10
  5. How to measure memory of Qt Application,
    By rajeshs in forum Qt Programming
    Replies: 2
    Last Post: 10th July 2007, 17:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.