• 3137阅读
  • 0回复

zhengtianzuo系列-Qml圆形进度按钮 [复制链接]

上一主题 下一主题
离线zhengtianzuo
 

只看楼主 倒序阅读 楼主  发表于: 2017-11-14
首先从方形到圆形的转变只需要更改Rectangle的radius值就行了
转变成圆形后就可以出现圆形进度条

```
Rectangle{
        property int btnHeight: 48
        property int btnWidth: 120

        id: cProBtn
        height: btnHeight
        width: btnWidth
        anchors.centerIn: parent
        border.color: "#148014"
        border.width: 2
        radius: 0
        Text{
            id: cText
            anchors.centerIn: parent
            font.family: "microsoft yahei"
            font.pixelSize: 14
            text: qsTr("开始")
        }
        MouseArea{
            anchors.fill: parent
            onClicked: {
                if (rAniStart.running || rAniStop.running) return
                cText.visible = false;
                rAniStart.start();
                widthAniStart.start();
            }
        }
        PropertyAnimation{
            id: rAniStart
            target: cProBtn
            property: "radius"
            duration: 300
            from: 0
            to: cProBtn.btnHeight/2
            onStopped: {
                cProgress.onStart();
                cProgress.visible = true;
            }
        }
        PropertyAnimation{
            id: widthAniStart
            target: cProBtn
            property: "width"
            duration: 300
            from: cProBtn.btnWidth
            to: cProBtn.btnHeight
        }
        QmlCircularProgress{
            id: cProgress
            anchors.centerIn: parent
            visible: false
            arcWidth: 2
            radius: cProBtn.btnHeight/2
            interval: 2
            arcColor: "#148014"
            onSStop: {
                visible = false;
                rAniStop.start();
                widthAniStop.start();
            }
        }
        PropertyAnimation{
            id: rAniStop
            target: cProBtn
            property: "radius"
            duration: 300
            from: cProBtn.btnHeight/2
            to: 0
            onStopped: {
                cText.text = qsTr("完成");
                cText.visible = true;
            }
        }
        PropertyAnimation{
            id: widthAniStop
            target: cProBtn
            property: "width"
            duration: 300
            from: cProBtn.btnHeight
            to: cProBtn.btnWidth
        }
    }
```



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