Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Super Contributor
JeffLemon
Posts: 391
Registered: ‎01-13-2011
My Carrier: NA

QTimer - get time?

Is it possible to set off a timer, and get the time elapsed later, say when a user clicks a button?

 

Thanks

--------------------------------------------------------------------------------------------------
BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone
Please use plain text.
Developer
peter9477
Posts: 5,624
Registered: ‎12-08-2010
My Carrier: none

Re: QTimer - get time?

Timers are not for measuring elapsed time, but merely for waking you up at some future point.

If you want to measure elapsed time, just record the starting time when some event happens, then later when the user clicks the button, record the time again and subtract the two values. No QTimer required.

Peter Hansen -- (PlayBook and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
peter9477
Posts: 5,624
Registered: ‎12-08-2010
My Carrier: none

Re: QTimer - get time?

And by "record the time" I mean of course use the JavaScript Date class, generally something like "var x = new Date()", possibly with an extra .getTime() added to pull out the time in milliseconds.

Peter Hansen -- (PlayBook and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Regular Contributor
Q-T
Posts: 69
Registered: ‎12-02-2011
My Carrier: none

Re: QTimer - get time?

See QTime's start(), ellapsed(), and restart() methods.

Please use plain text.