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
New Developer
PlayBookDave
Posts: 52
Registered: ‎01-09-2012
My Device: PlayBook

QTimer

How is the QTimer called in cascades  and where do i find it in "Gold" NDK 10.2.0 to add it my project ?

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: QTimer

Please try forum search (box near upper right) before asking. That would have found several threads including the top one: http://supportforums.blackberry.com/t5/Native-Development/QTimer-and-qmlRegisterType/m-p/2038545/hig...

 

Basically you have to register the class name yourself so QML can find it, but after that it's straightforward to use. Should be the same in 10.2 as earlier, I believe.


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!
New Developer
PlayBookDave
Posts: 52
Registered: ‎01-09-2012
My Device: PlayBook

Re: QTimer

yeah well thanks My code worked prior to NDK 10.2.0 then after stopped working right after .

I did have it registered like so

qmlRegisterType<QTimer>("my.library", 1, 0, "QTimer");

 

Now the code no longer works and the attached objects section doesn't fire.

How do i get it to work now with 10.2.0 like it did with the previous version ?

New Developer
PlayBookDave
Posts: 52
Registered: ‎01-09-2012
My Device: PlayBook

Re: QTimer

"Basically you have to register the class name yourself so QML can find it, but after that it's straightforward to use. Should be the same in 10.2 as earlier, I believe."

 

Better check that cause it doesn't work

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: QTimer

Okay, it wasn't apparent that you had it working earlier and that it was 10.2 alone that was the issue. I haven't started testing with 10.2 builds yet so I'm afraid I can't help.

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
RileyGB
Posts: 284
Registered: ‎08-06-2010
My Device: Z10

Re: QTimer

I strongly recommend using QTimer from C++ and use signals/slots to communicate to QML when needed. It will save you many headaches as opposed to trying to expose it to QML and starting the timer logic there.



Follow me on twitter @RileyGB - https://twitter.com/RileyGB
View my BB10 OpenSource projects - https://github.com/RileyGB/BlackBerry10-Samples
New Developer
PlayBookDave
Posts: 52
Registered: ‎01-09-2012
My Device: PlayBook

Re: QTimer

So QTimer i no longer supportted in cascades ?

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: QTimer

I'm quite sure QTimer is still supported in 10.2. It's so widely used it would be a huge note in large print in the Release Notes if it were gone.

I also can't agree with Riley's advice, certainly not yet and not to "strongly recommend" against using it. I've had zero issues with QTimer in QML and it's worked fine for all purposes I've needed. Complicating things by pushing that into C++ makes no sense to me. Think about it... the QTimer is already a C++ class, and you've exposed it to QML with the registerType call. Adding another layer around that just means you've got your own code registered for QML to use, and the QTimer is still there doing what it would have done anyway.

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!
New Developer
PlayBookDave
Posts: 52
Registered: ‎01-09-2012
My Device: PlayBook

Re: QTimer

I don't think its supported because i don't see QTimer available as an object for addition as an object .

Under add attached object it missing.

If its there where is it ??

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: QTimer

Presumably you included the proper import line at the top of that particular QML file, like this:

import my.library 1.0

If so, it may simply be that Momentics doesn't manage to parse and recognize the situation... I don't know if it has any way to understand that your app code actually registers that class for use in QML. If you have the import line, try just building the app and running it... it may well work even if the IDE isn't smart enough to update the list of available items for you.

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!