• 定时器Timer


    1、属性

    interval:int  间隔时间

    repeat:bool  是否重复

    running:bool  查询当前状态

    triggeredOnStart:bool  定时器开启即运行一次回调

    2、信号

    triggered  间隔时间到了发出此信号

    3、方法

    restart  重启

    start  开启

    stop  停止

    4、列子,软件开启Text自减1

    import QtQuick 2.6
    import QtQuick.Window 2.2
    import QtQuick.Controls 1.4
    
    Window {
        id:main;
        visible: true
         360
        height: 360
        Text{
            id:text;
             50;
            height: 30;
            text: "10";
            color: "red";
            font.pixelSize: 30;
            horizontalAlignment: Text.AlignHCenter;
            property int count;
            anchors.centerIn: parent;
            Component.onCompleted: {
                text.count = 10000000;
            }
            Timer{
                id:timer;
                interval : 1000;
                repeat: true;
                triggeredOnStart: true;
                onTriggered: {
                    if(text.count>0)
                    {
                        text.text  = text.count;//这里说明了QML是弱类型,不需要int转String
                        text.count--;
                    }
                }
                Component.onCompleted: {
                    timer.start();
                }
            }
        }
    }

  • 相关阅读:
    js 简单排序
    封装Vue轮播图
    MonggoDB 基本操作
    Node + MVC模式 登录注册 小示例
    Node__Express
    Canvas 碎碎念
    vue 动态添加 删除 属性
    Vue 下 浏览器 点击实现复制功能
    电脑共享无线网
    抓包tcpdump
  • 原文地址:https://www.cnblogs.com/judes/p/9453512.html
Copyright © 2020-2023  润新知