• 2870阅读
  • 0回复

zhengtianzuo系列-Qml进度条 [复制链接]

上一主题 下一主题
离线zhengtianzuo
 

只看楼主 倒序阅读 楼主  发表于: 2017-10-31
基本上是官网例子上加了一些方法

```
ProgressBar {
    property color proColor: "#148014"
    property color proBackgroundColor: "#AAAAAA"
    property int proWidth: 2
    property real progress: 0
    property real proRadius: 3
    property alias interval: timer.interval

    function isRunning(){
        return(timer.running)
    }

    function onStart(){
        cProgress.progress = 0;
        timer.running = true;
    }

    function onStop(){
        timer.running = false;
    }

    id: cProgress
    anchors.centerIn: parent
    value: (progress/100)
    padding: 2

    background: Rectangle {
        implicitWidth: 200
        implicitHeight: 16
        color: cProgress.proBackgroundColor
        radius: cProgress.proRadius
    }

    contentItem: Item {
        implicitWidth: 200
        implicitHeight: 10

        Rectangle {
            width: cProgress.visualPosition * parent.width
            height: parent.height
            radius: 2
            color: cProgress.proColor
        }
    }

    Timer{
        id: timer
        running: false
        repeat: true
        interval: 50
        onTriggered:{
            cProgress.progress++;
            if (cProgress.progress > 100){
                cProgress.onStop();
                return;
            }
        }
    }
}
```




需要完整代码请访问 QtQuickExamples
博客地址: https://blog.csdn.net/zhengtianzuo06
Github: https://github.com/zhengtianzuo
个人产品: https://github.com/zhengtianzuo/Silk
产品网站: http://www.camelstudio.cn
快速回复
限100 字节
 
上一个 下一个