2012-07-23 95 views
0

目前我尝试动画QGraphicsItem在他的Qt::YAxis。 我在这里有这个示例代码,但它不起作用,导致QGraphicsPixmapItem没有属性“变换”。转换/旋转QGraphicsItem w /动画Qt,C++

QPropertyAnimation *animation = new QPropertyAnimation(myQGraphPixItem, "transform"); 
animation->setDuration(10000); 
animation->setStartValue(QTransform::rotate (0, Qt::YAxis)); 
animation->setEndValue(QTransform::rotate (60, Qt::YAxis)); 

animation->start(); 

那么我该如何做到这一点?

回答

0

声明你自己的转换属性

class YourItem : public QGraphicsPixmapItem 
{ 
    Q_OBJECT 
    Q_PROPERTY(QTransform transfrom READ transform WRITE setTransform) 
    ... 
}; 
+0

但我不能做一个动画呢? – user1533754 2012-07-23 10:34:49