BlackBerry 10中是否有计时器在指定的时间间隔后运行您的功能? [英] Is there a timer in BlackBerry 10 that runs your functions after a specified time interval?

查看:62
本文介绍了BlackBerry 10中是否有计时器在指定的时间间隔后运行您的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了Internet,但是关于BlackBerry 10开发的文档很少. BlackBerry 10中是否有某些功能可以让您在指定的时间间隔后永久运行某个功能?就像iPhone/Objective-C中的NSTimer可以每隔大约x分钟运行一次功能.

I searched the internet but there is very little documentation available on BlackBerry 10 development. Is there something in BlackBerry 10 that allows you to run a function forever after specified intervals of time? Like there is NSTimer in iPhone/Objective-C that can run a function after every x minutes or so.

推荐答案

如@Sorry_Boss所指出的,您可以使用 QTimer 上的C ++代码.如果您想在QML中进行此操作,还可以将其注册以在QML中使用在您的应用类的构造函数中,如下所示:

As pointed by @Sorry_Boss, you can use QTimer on C++ code. If you want to do that in QML, you can also register it for use in QML in the constructor of your app class, like this:

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

然后,您可以将其导入QML文件中:

Then, you can import it in your QML file:

import my.library 1.0

...并将其用作附加到另一个组件的对象:

... and use it as an attached object to another component:

attachedObjects: [
    QTimer {
        id: timer
        interval: 1000 // 1 second
        onTimeOut {
            // do something
        }
    }
]

这篇关于BlackBerry 10中是否有计时器在指定的时间间隔后运行您的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆