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.

inside custom component

Native Development

Reply
Super Contributor
JeffLemon
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook

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
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

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 -- (BB10 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!
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

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 -- (BB10 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!
Regular Contributor
Q-T
Posts: 94
Registered: ‎12-02-2011
My Device: non-Blackberry user

Re: QTimer - get time?

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