条纹进度条

article/2025/8/23 20:13:37

最开始学习qml的时候,想实现一个条纹进度条,当时还不熟悉动画,做不出来,只做了个静止的。qml学习和使用了快1年之际,把这个遗憾弥补下。

先上效果图,颜色取自Bootflat。


以下是源码,先上StripeProgressBar.qml

import QtQuick 2.7
import QtQuick.Controls 2.1ProgressBar {id: controlimplicitWidth: Math.max(background ? background.implicitWidth : 0,contentItem.implicitWidth + leftPadding + rightPadding)implicitHeight: Math.max(background ? background.implicitHeight : 0,contentItem.implicitHeight + topPadding + bottomPadding)property bool stripe: falseproperty color backgroundColor: "#E6E9ED"property color stripeColor: "#5EBDE1"property color progressColor: "#3BAFDA"background: Rectangle {implicitWidth: 200implicitHeight: 20x: control.leftPaddingy: control.topPadding + (control.availableHeight - height) / 2width: control.availableWidthcolor: control.backgroundColorradius: 3}contentItem: Item{implicitWidth: 200implicitHeight: 20Rectangle {width: control.visualPosition * parent.widthheight: parent.heightcolor: control.progressColorclip:trueradius: 3Canvas{id:canvasvisible: control.stripewidth: parent.width*2height: parent.heightcontextType: "2d"function rounding(value,base){return Math.ceil(value/base)*base}SequentialAnimation {loops: Animation.Infiniterunning: canvas.visibleNumberAnimation {target: canvasproperty: "x"from: 0to: -canvas.height*2duration: 1900}ScriptAction {script: canvas.x = 0}}onPaint: {context.fillStyle=control.stripeColorcontext.lineWidth=0var startPostion=0var stripeWidth=parent.heightvar coupleStripeWidth=stripeWidth*2var stopPosion=rounding(parent.width+coupleStripeWidth,coupleStripeWidth)for(var loop=startPostion;loop<stopPosion;loop+=coupleStripeWidth){context.beginPath();context.moveTo(loop,0)context.lineTo(loop+stripeWidth,0)context.lineTo(loop+coupleStripeWidth,stripeWidth)context.lineTo(loop+stripeWidth,stripeWidth)context.lineTo(loop,0)context.closePath();context.fill()}}}}}
}
再上main.qml

import QtQuick 2.7
import QtQuick.Controls 2.0ApplicationWindow {visible: truewidth: 640height: 480title: qsTr("Hello World")Flow{anchors.fill: parentanchors.leftMargin: 100anchors.topMargin: 50spacing: 30StripeProgressBar{width: 400value: 0.3}StripeProgressBar{width: 400value: 0.3stripe: true}StripeProgressBar{width: 400value: 0.35stripe: trueprogressColor: "#8CC152"stripeColor: "#9DCA6B"}StripeProgressBar{width: 400value: 0.4stripe: trueprogressColor: "#3CBC9B"stripeColor: "#54C6A9"}StripeProgressBar{width: 400value: 0.5stripe: trueprogressColor: "#F6BB42"stripeColor: "#F7C55E"}StripeProgressBar{width: 400value: 0.55stripe: trueprogressColor: "#DA4453"stripeColor: "#DF5F6C"}StripeProgressBar{width: 400value: 0.6stripe: trueprogressColor: "#4A89DC"stripeColor: "#5D9CEC"}StripeProgressBar{width: 400value: 1.0stripe: trueprogressColor: "#967ADC"stripeColor: "#AC92EC"}}
}





http://chatgpt.dhexx.cn/article/QXvF4NVo.shtml

相关文章

数据批量插入与逐条插入分析

简述 今天抽空做了一下使用Jdbc对数据操作的实际性能。在平时开发过程中我们经常会使用Hibernate来操作数据库&#xff0c;所以我们很少会去使用批量插入数据。一般都是通过hibernate的insert、addSave等方法来一条条地插入数据。所以很少去考虑这个问题。下面是针对Jdbc进行的…

css滚动条

此部分针对webkit内核的浏览器&#xff0c;使用伪类来改变滚动条的默认样式&#xff0c;详情如下&#xff1a; 滚动条组成部分 1. ::-webkit-scrollbar 滚动条整体部分2. ::-webkit-scrollbar-thumb 滚动条里面的小方块&#xff0c;能向上向下移动&#xff08;或向左向右移动…

计算机组成原理(五)-一条指令是怎么被执行的

什么是指令&#xff1a; 程序代码的本质就是一条一条的指令&#xff0c;我们需要通过编码的方式让CPU知道我们需要它干什么&#xff0c;最后由译码器翻译成一条条的机器指令。机器指令主要有两部分组成&#xff1a;操作码、地址码。地址码直接给出操作数和操作数的地址&#x…

CSS 斜条纹进度条动画

这是第一版进度条 ,用css写的.但是后续因为数据不同,要显示不同的颜色和数据,所以又改了一版,直接用的el-progress.自定义的样式.对于新手小白来说比较友好.先上这一版代码. <div class"state"><span>开机时间</span><!-- 进度条 --><div…

Acrobat DC 更改背景颜色会有一条条白色横纹

解决方法如下&#xff1a; 编辑->首选项->页面显示->取消 使用2D图形加速

turtle模块还能这样玩?(一条条金龙鱼、雨景)

文章目录 一条条金龙鱼雨景 Python的turtle模块不仅可以用来绘制一些基本的图形&#xff0c;还有与图片结合&#xff0c;做出一些特殊的效果&#xff0c;还可以用来做二维小游戏。本篇是介绍用turtle模块做出的一幅动态的鱼儿游过的画面和动态的雨景图 一条条金龙鱼 1、先看一…

2.Python # 代码注释

2. # 代码注释 文章目录 2. # 代码注释1. 什么是代码注释2. 注释语法3. 注释位置1. 注释在代码的上一行2. 注释在代码的末端 4. 课堂练习 1. 什么是代码注释 代码注释即对代码进行批注说明。 相当于给一个英文单词批注中文释义。 【温馨提示】注释是给程序员自己看的&#xf…

python:导入第三方库greenlet,gevent方法

greenlet&#xff0c;gevent greenlet&#xff0c;gevent是python支持的第三方库&#xff0c;它们可以帮助我们完成协程的使用&#xff0c;其中greenlet是手动调换方式&#xff08;switch方法&#xff09;&#xff0c;gevent是自动调换方式&#xff08;遇到IO操作&#xff09;…

python gevent使用

对大部分语言来说&#xff0c;经常用到并发来处理一些情况。比如必须要多次查询数据库&#xff0c;多次请求API&#xff0c;python内置的gevent就很简单好用。传参&#xff0c;获取返回值&#xff0c;捕获协程的错误都很方便。 直接上例子&#xff1a; import gevent as gevent…

指定Geany使用的Python版本

本文介绍&#xff1a; 在win7下配置Geany,使其使用 Python 3 因为电脑上安装了不同版本的Python&#xff0c;需要根据实际情况来进行版本切换。 第一步&#xff1a;首先点击"生成"按钮的三角箭头&#xff0c;再点击"设置生成命令" 第二步&#xff1a;在弹出…

ModuleNotFountError:No module named ‘gensim‘(在python代码中导入gensim模块)

运行窗口&#xff1a; conda install 模块 pip install 模块 第一个命令应该由于网速太慢没有下载完全&#xff0c;第二个命令我手动输入n退出了。 网速慢&#xff0c;可以使用如下命令&#xff1a; pip install -i https://pypi.douban.com/simple gensim pip install -i…

Python学习笔记--图例 legend

Python学习笔记--图例 legend 参靠视频:《Python数据可视化分析 matplotlib教程》链接&#xff1a;https://www.bilibili.com/video/av6989413/?p6 所用的库及环境: IDE:Pycharm Python环境&#xff1a;python3.7 Matplotlib: Matplotlib 1.11 Numpy&#xff1a; Numpy1.1…

【pybind11笔记】eigen与numpy数据交互

系列文章 【pybind11笔记】eigen与numpy数据交互 【pybind11笔记】python调用c函数 【pybind11笔记】python调用c结构体 【pybind11笔记】python调用c类 文件结构 为了方便演示&#xff0c;我们使用cmake构建该样例&#xff0c;文件结构如下&#xff1a; pybind11与eigen…

python学习笔记:问题一,Geany编辑器无法使用中文注释

python学习笔记&#xff1a; 问题一&#xff1a; Geany编辑器无法使用中文注释 Geany编译python时运行弹出SyntaxError: (unicode error) ‘utf-8’ codec can’t提升&#xff0c;文本编辑器Geany无法使用中文注释&#xff0c;可以设置一下文本编码格式就好了设置方法为&…

Python--注释

Python--注释 <font size4, colorblue> 一、Python中注释的形式<font size4, colorblue> 1、单行注释&#xff1a;使用“#”符号注释<font size4, colorblue> 2、多行注释&#xff1a;使用一对三个英文单引号注释<font size4, colorblue> 3、多行注释&…

python中generate什么意思_python generate怎么用

generate语句允许细化时间(Elaboration-time)的选取或者某些语句的重复。这些语句可以包括模块实例引用的语句、连续赋值语句、always语句、initial语句和门级实例引用语句等。细化时间是指仿真开始前的一个阶段&#xff0c;此时所有的设计模块已经被链接到一起&#xff0c;并完…

Python Gevent

参考资料 http://www.gevent.org/contents.htmlhttps://uwsgi-docs-zh.readthedocs.io/zh_CN/latest/Gevent.html Python脚本的执行效率一直来说并不是很高&#xff0c;特别是Python下的多线程机制&#xff0c;长久以来一直被人们诟病。很多人都在思考如何让Python执行的更快…

符号回归工具之 geppy: Python中的基因表达编程框架

符号回归工具之 geppy&#xff1a; Python中的基因表达编程框架 geppy是一个专门用于基因表达编程&#xff08;GEP&#xff09;的计算框架&#xff0c;由 C. Ferreira 在 2001 年提出 [1]。 geppy是在 Python 3 中开发的。这个框架个人认为稍微了解下遗传算法和遗传规划即可入…

如何在Geany中添加python的中文注释

在Geany中编译Python中直接添加中文注释会出现如下错误 只需要在程序的开始位置添加一句&#xff1a;# coding:utf-8

python中安装gensim包

安装gensim扩展包需要先安装numpy和scipy 先下载这三个文件的安装包。 注意安装包版本问题&#xff0c;可以进入python查看&#xff1a; 这里注意图中划线的两个地方即可&#xff0c;win代表的是是windows系统 WinR cmd 切换到安装包所在路径&#xff1a; pip install numpy…