(self, startPos, endPos)
| 74 | self.initAnimation(startPos, endPos) |
| 75 | |
| 76 | def initAnimation(self, startPos, endPos): |
| 77 | # 透明度动画 |
| 78 | opacityAnimation = QPropertyAnimation(self, b"opacity") |
| 79 | opacityAnimation.setStartValue(1.0) |
| 80 | opacityAnimation.setEndValue(0.0) |
| 81 | # 设置动画曲线 |
| 82 | opacityAnimation.setEasingCurve(QEasingCurve.InQuad) |
| 83 | opacityAnimation.setDuration(4000) # 在4秒的时间内完成 |
| 84 | # 往上移动动画 |
| 85 | moveAnimation = QPropertyAnimation(self, b"pos") |
| 86 | moveAnimation.setStartValue(startPos) |
| 87 | moveAnimation.setEndValue(endPos) |
| 88 | moveAnimation.setEasingCurve(QEasingCurve.InQuad) |
| 89 | moveAnimation.setDuration(5000) # 在5秒的时间内完成 |
| 90 | # 并行动画组(目的是让上面的两个动画同时进行) |
| 91 | self.animationGroup = QParallelAnimationGroup(self) |
| 92 | self.animationGroup.addAnimation(opacityAnimation) |
| 93 | self.animationGroup.addAnimation(moveAnimation) |
| 94 | self.animationGroup.finished.connect(self.close) # 动画结束时关闭窗口 |
| 95 | self.animationGroup.start() |
| 96 | |
| 97 | def paintEvent(self, event): |
| 98 | super(BubbleLabel, self).paintEvent(event) |
no test coverage detected