forked from zhengtianzuo/QtQuickExamples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQmlProgress.qml
69 lines (60 loc) · 1.18 KB
/
QmlProgress.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*!
*@file QmlProgress.qml
*@brief Qml进度条
*@version 1.0
*@section LICENSE Copyright (C) 2003-2103 CamelSoft Corporation
*@author zhengtianzuo
*/
import QtQuick 2.7
import QtQuick.Controls 2.2
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;
}
}
}
}