• 6002阅读
  • 1回复

关于QTimeLine的问题 [复制链接]

上一主题 下一主题
离线pywepe
 
只看楼主 倒序阅读 楼主  发表于: 2010-01-08


QGraphicsEllipseItem* sun=new QGraphicsEllipseItem(0,0,20,20);
    sun->setBrush(QBrush(Qt::red));
    sun->setPen(QPen(Qt::red));

    QTimeLine* timeLine=new QTimeLine(10000);
    timeLine->setCurveShape(QTimeLine::LinearCurve);

    QGraphicsItemAnimation* animation=new QGraphicsItemAnimation;
    animation->setItem(sun);
    animation->setTimeLine(timeLine);

    qreal x,y;
    qreal angle=PI;
    for(int i=0;i<=180;++i){
        x=200.0*cos(angle);
        y=200.0*sin(angle);
        animation->setPosAt(i/180.0,QPointF(x,y));
        angle+=PI/180.0;
    }

    QGraphicsScene* scene=new QGraphicsScene();
    scene->addItem(sun);

    QGraphicsView* view=new QGraphicsView(scene);
    view->resize(640,480);
    view->show();
    timeLine->setLoopCount(0);
    timeLine->start();


为什么timeLine->start() 之后 上面的for循环慢慢的执行呢?
timeLine是怎么执行的?或者说QGraphicsItemAnimation怎么执行的?

离线2nd090215
只看该作者 1楼 发表于: 2010-01-10
关注,
快速回复
限100 字节
 
上一个 下一个