Sunday, December 23, 2012

Using Timer with BB10 Cascades QML code

It is possible to use code Qt and QML API for BB10 development. But to get more native look and feel, I started exploring BB10 Cascades API.

Soon I started working with cascade API, I realized Timer QML element is now no longer available with Cascade QML API.

However you can export QTimer to cascade QML and use QTimer with your QML code.

Following example shows how that can be done.

First export QTimer to QML, by registering it with metasystem. You can put this code in main.cpp.

qmlRegisterType<QTimer>("my.library", 1, 0, "QTimer");
Then in QML file where you want to use QTimer import namespace where QTimer is exported, like below.
import my.library 1.0

Then define QTimer as attached object in QML.
attachedObjects: [
            id: timer
            //set singleshot property if requireds
            singleShot: true
            //set interval
            interval: 5000
                //do some stuff

You can start and stop timer by using it's id and then calling appropriate slots.
    function startTimer(){
    function stopTimer() {


  1. How about providing access to QtMobilitySubset in a QtQuick app?

    1. What particular feature you are looking for? As far as I know, there are API for most of feature in cascades as well.

    2. @Kunal:I want to remove a sheet after some duration. How we can do this in BB10 Cascades QML.

    3. I am not sure about exact sheet API, but you can call, close or hide or similar API once timer timeouts. May be i will try to create some sample