QML 自定义进度条样式
来源:互联网 发布:网络上口口是什么意思 编辑:程序博客网 时间:2024/05/17 23:35
QML 自定义进度条样式
此博客始创于:http://blog.csdn.net/lys211
转载请注明出处
修改的进度条样式,可以在此基础上根据期望改成自己喜欢的样子。
效果如下:
(应该是动态图,如果不是,那就奇怪了)
代码比较长,这里粘贴一份,同时会上传一份.
ProgressBarStyleView.qml
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Controls.Styles 1.2
import QtGraphicalEffects 1.0
import QtQml 2.2
Rectangle {
id:root;
color: "white";
visible: true;
width: 600;
height: 600;
ProgressBar {
id: progressBar;
x: 83
y: 39
width: 397;
height: 23;
value: 0.2;
style: ProgressBarStyle{
background: Rectangle{
border.width: 1;
border.color: control.hovered?"green":"#25b1e8";
color:"lightgray";
}
progress: Rectangle{
color: "#25b1e8"
}
}
}
ProgressBar {
id: progressBar1
x: 83
y: 101
width: 397
height: 23
value: 0.5;
style: ProgressBarStyle{
background: Rectangle{
border.width: 1;
border.color: "#25b1e8";
color:"lightgray";
}
progress: Rectangle{
color: "#25b1e8"
Text {
anchors.right: parent.right;
anchors.verticalCenter: parent.verticalCenter;
text: progressBar1.value;
color: "white"
}
}
}
}
ProgressBar {
id: progressBar2
x: 83
y: 167
width: 397
height: 23
value: 0.73;
style: ProgressBarStyle{
id:progressBarStyle;
background: Rectangle{
border.width: 1;
border.color: control.hovered?"green":"#25b1e8";
color:"lightgray";
}
progress: Rectangle{
color: "#25b1e8"
Text {
anchors.right: parent.right;
anchors.rightMargin: 5;
anchors.verticalCenter: parent.verticalCenter;
text: progressBar2.value*100 + "%";
color: "white"
}
}
panel: Item{
implicitHeight: 20;
implicitWidth: 200;
Loader{
anchors.fill: parent;
sourceComponent: background;
}
Loader{
anchors.top: parent.top;
anchors.left: parent.left;
anchors.bottom: parent.bottom;
anchors.margins: 2;
width: currentProgress * (parent.width - 4)
sourceComponent: progressBarStyle.progress;
}
}
}
}
Timer{
interval: 300;
running: true;
repeat: true;
onTriggered: {
if(progressBar3.value >= 1)
progressBar3.value = 0;
progressBar3.value += 0.05;
if(progressBar4.value >= 1)
progressBar4.value = 0;
progressBar4.value += 0.05;
}
}
ProgressBar {
id: progressBar3
x: 83
y: 226
width: 397
height: 23
value: 0.01;
style: ProgressBarStyle{
id:progressBar3Style;
background: Rectangle{
border.width: 1;
border.color: control.hovered?"green":"#25b1e8";
color:"lightgray";
Text {
anchors.right: parent.right;
anchors.rightMargin: 5;
anchors.verticalCenter: parent.verticalCenter;
text: Math.round(currentProgress*100) + "%";
color: "#25b1e8"
}
}
progress: Rectangle{
color: "#25b1e8";//
clip: true;
Rectangle{
anchors.left: parent.left;
//anchors.top: parent.top;
//anchors.bottom: parent.bottom;
height: progressBar3.width;
width: progressBar3.width;
LinearGradient{
anchors.fill: parent;
gradient: Gradient {
GradientStop {
position: 0.00;
color: "#ffffff";
}
GradientStop {
position: 1.00;
color: "#36d1e8";
}
}
start:Qt.point(0, 0);
end: Qt.point(parent.width, 0);
}
}
}
panel: Item{
implicitHeight: 20;
implicitWidth: 200;
Loader{
anchors.fill: parent;
sourceComponent: background;
}
Loader{
anchors.top: parent.top;
anchors.left: parent.left;
anchors.bottom: parent.bottom;
anchors.margins: 2;
width: currentProgress * (parent.width - 4)
sourceComponent: progressBar3Style.progress;
}
}
}
}
ProgressBar {
id: progressBar4
x: 83
y: 289
width: 397
height: 23
value: 0.01;
property color colorValue: Qt.rgba(37/255, 177/255, 232/255, 1);
style: ProgressBarStyle{
id:progressBar4Style;
background: Rectangle{
border.width: 1;
border.color: control.hovered?"green":"#25b1e8";
color:"lightgray";
}
progress: Rectangle{
//color: "#25b1e8";//
//color: Math.round(currentProgress*100);
color: progressBar4.colorValue;
onColorChanged: {
console.log("onColorChanged")
}
}
panel: Item{
implicitHeight: 20;
implicitWidth: 200;
Loader{
anchors.fill: parent;
sourceComponent: background;
}
Loader{
anchors.top: parent.top;
anchors.left: parent.left;
anchors.bottom: parent.bottom;
anchors.margins: 2;
width: currentProgress * (parent.width - 4)
sourceComponent: progressBar4Style.progress;
onWidthChanged: {
console.log("onWidthChanged")
progressBar4.colorValue = Qt.rgba(1-currentProgress, 1-currentProgress, 1-currentProgress, 1)
}
}
Text {
anchors.right: parent.right;
anchors.rightMargin: 5;
anchors.verticalCenter: parent.verticalCenter;
text: Math.round(currentProgress*100) + "%";
color: "#25b1e8"
}
}
}
}
}
整个文件可下载,地址是:
http://download.csdn.net/detail/lys211/8541135
0 0
- QML 自定义进度条样式
- QML自定义鼠标样式
- flex自定义进度条样式
- android自定义进度条样式
- Android自定义进度条样式
- Android自定义进度条样式
- 自定义进度条样式
- 自定义 进度条 样式
- 自定义进度条样式
- 自定义进度条样式progressBar
- QML 自定义button样式1
- 自定义 ProgressBar 进度条 自定义样式
- 自定义 ProgressBar 进度条 自定义样式
- Android Material Design 进度条 自定义进度条样式
- android 进度条seekbar样式自定义
- android 进度条seekbar样式自定义
- 自定义的环形进度条样式
- android进度条seekbar自定义样式
- Python 字典(Dictionary)操作详解
- 【j2ee spring】7、spring与数据库的连接的操作事务管理
- java网络编程---udp
- android powerkey触发小应用总结
- 第三周项目5-4:数组作成员数据-数据保存
- QML 自定义进度条样式
- Servlet 3.0 新特性详解(二)异步处理支持
- UVA 12301 - An Angular Puzzle(计算几何)
- hdu 2647 Reward 拓扑排序。
- LeetCode OJ Word Ladder II
- php 面试题收集
- android获取多媒体库的视频、音频、图片
- CCTV10专题《重访---黑客江湖》
- Subsets