QML 分享各种 BusyIndicator loading 加载中...


动画效果还是要好好学习啊。

1. 各种加载状态…

demo 来自 https://github.com/Furkanzmc/QML-Loaders
csdn 地址: https://download.csdn.net/download/u011942101/85248536
效果如下:
在这里插入图片描述

2. 圆形进度条

效果如下:
在这里插入图片描述

代码如下

import QtQuick 2.9

Item {
    id: root

    property int size: 150
    property int lineWidth: 5
    property real value: 0

    property color primaryColor: "#29b6f6"
    property color secondaryColor: "#e0e0e0"

    property int animationDuration: 1000

    width: size
    height: size


    onValueChanged: {
        canvas.degree = value * 360;
    }


    Canvas {
        id: canvas

        property real degree: 0

        anchors.fill: parent
        antialiasing: true

        onDegreeChanged: {
            requestPaint();
        }

        onPaint: {
            var ctx = getContext("2d");

            var x = root.width/2;
            var y = root.height/2;

            var radius = root.size/2 - root.lineWidth
            var startAngle = (Math.PI/180) * 270;
            var fullAngle = (Math.PI/180) * (270 + 360);
            var progressAngle = (Math.PI/180) * (270 + degree);

            ctx.reset()

            ctx.lineCap = 'round';
            ctx.lineWidth = root.lineWidth;

            ctx.beginPath();
            ctx.arc(x, y, radius, startAngle, fullAngle);
            ctx.strokeStyle = root.secondaryColor;
            ctx.stroke();

            ctx.beginPath();
            ctx.arc(x, y, radius, startAngle, progressAngle);
            ctx.strokeStyle = root.primaryColor;
            ctx.stroke();
        }

        Behavior on degree {
            NumberAnimation {
                duration: root.animationDuration
            }
        }
    }
}
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.4

Window {
    visible: true
    width: 1280
    height: 800
    title: qsTr("CircularProgressBar - Demo")

    Row {
        anchors.centerIn: parent
        spacing: 20

        CircularProgressBar {
            id: progress1
            lineWidth: 10
            value: 0.1
            size: 150
            secondaryColor: "#e0e0e0"
            primaryColor: "#29b6f6"

            Text {
                text: parseInt(progress1.value * 100) + "%"
                anchors.centerIn: parent
                font.pointSize: 20
                color: progress1.primaryColor
            }
        }

        CircularProgressBar {
            id: progress2
            lineWidth: 10
            value: 0.33
            size: 150
            secondaryColor: "#e0e0e0"
            primaryColor: "#ab47bc"

            Text {
                text: parseInt(progress2.value * 100) + "%"
                anchors.centerIn: parent
                font.pointSize: 20
                color: progress2.primaryColor
            }
        }

        CircularProgressBar {
            id: progress3
            lineWidth: 10
            value: 0.50
            size: 150
            secondaryColor: "#e0e0e0"
            primaryColor: "#9ccc65"

            Text {
                text: parseInt(progress3.value * 100) + "%"
                anchors.centerIn: parent
                font.pointSize: 20
                color: progress3.primaryColor
            }
        }

        CircularProgressBar {
            id: progress4
            lineWidth: 10
            value: 0.75
            size: 150
            secondaryColor: "#e0e0e0"
            primaryColor: "#f44336"

            Text {
                text: parseInt(progress4.value * 100) + "%"
                anchors.centerIn: parent
                font.pointSize: 20
                color: progress4.primaryColor
            }
        }

        CircularProgressBar {
            id: progress5
            lineWidth: 10
            value: 1
            size: 150
            secondaryColor: "#e0e0e0"
            primaryColor: "#4db6ac"

            Text {
                text: parseInt(progress5.value * 100) + "%"
                anchors.centerIn: parent
                font.pointSize: 20
                color: progress5.primaryColor
            }
        }

        CircularProgressBar {
            id: progress6
            lineWidth: 10
            value: 0.4
            size: 150
            secondaryColor: "#e0e0e0"
            primaryColor: "#4db6ac"

            Text {
                text: parseInt(progress5.value * 100) + "%"
                anchors.centerIn: parent
                font.pointSize: 20
                color: progress5.primaryColor
            }
        }
    }
}
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值