QML控件类型:ProgressBar、BusyIndicator

ProgressBar

一、描述

ProgressBar 指示操作的进度。

二、属性成员

1、from : real

起始值。默认为 0.0。

      to : real

最终值。 默认为 1.0。

      value : real

进度值。默认为 0.0。 

2、indeterminate : bool

进度条是否处于不确定模式。

不确定模式下的进度条显示操作正在进行中,但不显示已取得多少进展。

import QtQuick 2.14
import QtQuick.Window 2.14
import QtQuick.Controls

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    ProgressBar {
    }
    ProgressBar {
        y:50
        value: 0.5
    }
    ProgressBar {
        y:100
        indeterminate: true
    }
}

3、【只读】 position : real

进度条的逻辑位置(因为进度条有方向)。范围为 0.0 - 1.0。

4、【只读】 visualPosition : real

进度条的视觉位置。范围为 0.0 - 1.0。当控件被镜像时,visuaPosition 等于 1.0 - position。 这使得 visualPosition 适合可视化进度,同时考虑到从右到左的支持。

三、自定义 ProgressBar 示例

import QtQuick
import QtQuick.Controls

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    ProgressBar {
        id: control
        value: 0.5
        padding: 2

        background: Rectangle {
            implicitWidth: 200
            implicitHeight: 6
            color: "#e6e6e6"
            radius: 3
        }

        contentItem: Item {
            implicitWidth: 200
            implicitHeight: 4

            Rectangle {
                width: control.visualPosition * parent.width
                height: parent.height
                radius: 2
                color: "#17a81a"
            }
        }
    }
}

 


BusyIndicator

一、描述

忙碌指示符,用于指示正在加载内容或 UI 被阻止等待资源可用时的活动。

二、属性成员

1、running : bool

忙碌指示器当前是否正在指示活动。指示器仅在此属性设置为 true 时可见。默认为 true。

三、自定义 BusyIndicator 示例

import QtQuick
import QtQuick.Controls

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    BusyIndicator {
        id: control

        contentItem: Item {
            implicitWidth: 64
            implicitHeight: 64

            Item {
                id: item
                x: parent.width / 2 - 32
                y: parent.height / 2 - 32
                width: 64
                height: 64
                opacity: control.running ? 1 : 0

                Behavior on opacity {
                    OpacityAnimator {
                        duration: 250
                    }
                }

                RotationAnimator {
                    target: item
                    running: control.visible && control.running
                    from: 0
                    to: 360
                    loops: Animation.Infinite
                    duration: 1250
                }

                Repeater {
                    id: repeater
                    model: 6

                    Rectangle {
                        id: delegate
                        x: item.width / 2 - width / 2
                        y: item.height / 2 - height / 2
                        implicitWidth: 10
                        implicitHeight: 10
                        radius: 5
                        color: "#21be2b"

                        required property int index

                        transform: [
                            Translate {
                                y: -Math.min(item.width, item.height) * 0.5 + 5
                            },
                            Rotation {
                                angle: delegate.index / repeater.count * 360
                                origin.x: 5
                                origin.y: 5
                            }
                        ]
                    }
                }
            }
        }
    }
}

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值