我想将 anim_2 转换为旋转,但我不知道如何或即使它可能。我尝试将 QPropertyAnimation 与 (b"angle") 一起使用,但它什么也不做。有什么帮助或想法吗?谢谢!
import sys
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
class Window(QWidget):
def __init__(self):
super().__init__()
self.resize(600, 600)
self.child = QWidget(self)
self.child.setStyleSheet("background-color:red;border-radius:15px;")
self.child.resize(100, 100)
self.anim = QPropertyAnimation(self.child, b"pos")
self.anim.setEndValue(QPoint(200, 200))
self.anim.setDuration(1500)
self.anim_2 = QPropertyAnimation(self.child, b"angle")
self.anim_2.setStartValue(90)
self.anim_2.setEndValue(270)
self.anim_2.setDuration(2000)
self.anim_2.setLoopCount(-1)
self.anim_group = QSequentialAnimationGroup()
self.anim_group.addAnimation(self.anim)
self.anim_group.addAnimation(self.anim_2)
self.anim_group.start()
app=QApplication([])
MW=Window()
MW.show()
app.exec_()