Results 1 to 2 of 2

Thread: Creating count down timer in Qt

  1. #1
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default Creating count down timer in Qt

    I wish to understand this line:
    Qt Code:
    1. objTime->setHMS (0, objTime->addSecs (-1).minute (), objTime->addSecs (-1).second ());
    To copy to clipboard, switch view to plain text mode 

    How does this decrease the minutes and seconds?

    From here: http://doc.qt.nokia.com/4.7/qtime.html#addSecs

    Qt Code:
    1. QTime n(14, 0, 0); // n == 14:00:00
    2. t = n.addSecs(70); // t == 14:01:10
    3. t = n.addSecs(-70); // t == 13:58:50
    To copy to clipboard, switch view to plain text mode 
    `addSecs` function perhaps adds or subtracts seconds. Fine. But what does this do objTime->addSecs (-1).minute ()?

    How does setHMS work (in the current case)?

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

    Default Re: Creating count down timer in Qt

    Remember that QTime::addSecs() CREATES new QTime instance and don't change yourself.
    So this is equivalent to :
    Qt Code:
    1. QTime time_dec = objTime->addSecs (-1);
    2. objTime->setHMS (0, time_dec.minute(), time_dec.second());
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. timer problem(timer does not work)
    By masuk in forum Newbie
    Replies: 6
    Last Post: 14th February 2011, 05:00
  2. QString resize() or count()
    By nagabathula in forum Qt Programming
    Replies: 6
    Last Post: 27th December 2010, 12:55
  3. Replies: 0
    Last Post: 17th March 2010, 12:17
  4. Count indexes in QListView
    By been_1990 in forum Qt Programming
    Replies: 5
    Last Post: 17th December 2009, 19:21
  5. [QGLWidget] Count FPS
    By Macok in forum Qt Programming
    Replies: 0
    Last Post: 13th April 2009, 14:01

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
  •  
Qt is a trademark of The Qt Company.