Results 1 to 6 of 6

Thread: Timer not timing out?

  1. #1
    Join Date
    Jan 2006
    Posts
    46
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Timer not timing out?

    I have in the constructor:

    Qt Code:
    1. MazeField::MazeField( QWidget *parent, const char *name ) : QWidget( parent, name ) {
    2. (...)
    3. recordingTimer = new QTimer( this, "recordingTimer" );
    4. connect(recordingTimer,SIGNAL(timeout()),this,SLOT(updateRecordingTime()));
    5. (...)
    6. }
    To copy to clipboard, switch view to plain text mode 

    and in the same file, below:
    Qt Code:
    1. void MazeField::updateRecordingTime() {
    2. recordingTimerCount = (unsigned) time (NULL) - recordingTimerStart;
    3. cout << "Recording time is " << recordingTimerCount << endl;
    4. emit recordingTimeChanged(recordingTimerCount);
    5. }
    To copy to clipboard, switch view to plain text mode 

    But this last bit doesn't seem to get reached, it doesn't even write the time...

    Please help.

    Mariane

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Timer not timing out?

    How do you start that timer?

  3. #3
    Join Date
    Jan 2006
    Posts
    46
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Timer not timing out?

    Start? I thought they just started when declared

    Mariane

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Timer not timing out?

    No, you have to start() them. And that's reasonable, because you can use a single timer multiple times.

  5. #5
    Join Date
    Jan 2006
    Posts
    46
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Timer not timing out?

    Thank you very much.

    Mariane

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Timer not timing out?

    Here's an example from Qt docs:
    Qt Code:
    1. QTimer *timer = new QTimer( myObject );
    2. connect( timer, SIGNAL(timeout()), myObject, SLOT(timerDone()) );
    3. timer->start( 2000, TRUE ); // 2 seconds single-shot timer
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. implemet a timer
    By adamatic in forum Qt Programming
    Replies: 12
    Last Post: 17th February 2009, 07:31
  2. how to enable a timer in a non-gui thread?
    By zeopha in forum Qt Programming
    Replies: 3
    Last Post: 5th August 2008, 09:29
  3. Timer for application
    By Zergi in forum Qt Programming
    Replies: 3
    Last Post: 26th December 2007, 22:21
  4. Thread(s) and socket, timer slots
    By stephdev1965 in forum Qt Programming
    Replies: 1
    Last Post: 8th November 2006, 14:04
  5. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36

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.