马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- import QtQuick
- import QtQuick.Controls
- import QtQuick.Layouts
- Window {
- width: 640
- height: 480
- visible: true
- title: qsTr("Hello World")
- property int timeCount:0
- Text {
- id: txt1
- text: qsTr("text")
- anchors.centerIn: parent
- }
- Timer{
- id: timer1
- interval: 1000
- // running: false
- repeat: true
- triggeredOnStart: true // 定时器一启动就触发一次
- onTriggered:{
- timeCount ++
- txt1.text = "time count " + timeCount
- }
- }
- Column{
- id:idRow
- spacing: 10
- Button{
- id: btn1
- text: "start"
- onClicked: {
- timer1.start()
- }
- }
- Button{
- id: btn2
- text: "pause"
- onClicked: {
- timer1.stop()
- }
- }
- Button{
- id: btn3
- text: "restart"
- onClicked: {
- timer1.restart()
- }
- }
- Component.onCompleted: {
- console.log("row width = ",width, " row height = ", height);
- }
- }
- }
复制代码 timer 的interval表现的是时间隔断,ontrigger表现定时器到达时间隔断后的回调函数。repeate是表现start后ontrigger回调一次照旧连续回调。timer.start()表现开启定时器,restart()表现重新开启定时器,如果开没到达interval时间,则重新计时。stop()函数表现暂停。
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |