Skip to content

Commit cda0091

Browse files
committed
优化动画不连贯以及出现方向
1 parent 2925ff6 commit cda0091

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

QProgressBar/ColourfulProgress.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,20 @@ def paintEvent(self, _):
144144
self._animation.start()
145145

146146
# 动画斜线绘制
147-
if (vertical and inverted) or (not vertical and not inverted):
147+
startX = int(progressBar.left() - rect.height() - self._lineWidth)
148+
endX = int(rect.right() + self._lineWidth)
149+
150+
if (not inverted and not vertical) or (inverted and vertical):
148151
lines = [
149152
QLineF(x + step, progressBar.bottom(),
150153
x + rect.height() + step, progressBar.top())
151-
for x in range(int(progressBar.left() - rect.height()),
152-
int(rect.right()), self._lineWidth)
154+
for x in range(startX, endX, self._lineWidth)
153155
]
154156
else:
155157
lines = [
156-
QLineF(x - step, progressBar.top(),
157-
x + rect.height() - step, progressBar.bottom())
158-
for x in range(int(progressBar.left() - rect.height()),
159-
int(rect.right()), self._lineWidth)
158+
QLineF(x - step, progressBar.bottom(),
159+
x + rect.height() - step, progressBar.top())
160+
for x in range(startX, endX, self._lineWidth)
160161
]
161162
painter.drawLines(lines)
162163

QProgressBar/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@
5050
## 7、多彩动画进度条
5151
[运行 ColourfulProgress.py](ColourfulProgress.py)
5252

53-
动画实现参考 qfusionstyle.cpp 中的 CE_ProgressBarContents 绘制方法,存在一点角落地方动画连贯性小问题
53+
动画实现参考 qfusionstyle.cpp 中的 CE_ProgressBarContents 绘制方法
5454

5555
![ColourfulProgress](ScreenShot/ColourfulProgress.gif)
430 KB
Loading

0 commit comments

Comments
 (0)