我遇到了一个小问题,因为我无法通过如下方式重写setPos方法来创建一个简单的setPos动画:
def setPos(self, pos):
print('from %s to %s' % (self.scenePos(), pos))
timer = QTimeLine(5000)
timer.setFrameRange(0, 100)
animation = QGraphicsItemAnimation()
animation.setItem(self)
animation.setTimeLine(timer)
x_step = (pos - self.scenePos()).x() / 200
y_step = (pos - self.scenePos()).y() / 200
for i in range(200):
animation.setPosAt(i/200, self.scenePos() + QPointF(i * x_step, i * y_step))
timer.start()
提前谢谢,b52
@robe:QPropertyAnimation要求声明类是一个QObject,我相信QGraphicsItem不是。在
为什么不使用QPropertyAnimation?。使用这个类,您可以为对象的任何属性创建动画。在
你应该努力避免很多冲突。在
相关问题 更多 >
编程相关推荐