QT 设置QGraphicsItem动起来


QGraphicsLineItem *line;

    scene->addItem(line = new QGraphicsLineItem(QLineF(QPointF(0, 0), QPointF(300, 300))));   //在创景窗口中画一条直线
    line->setPen(QPen(Qt::DashDotDotLine));

    QGraphicsItemAnimation *animation = new QGraphicsItemAnimation;
    animation->setItem(line);
    //scene->addItem(animation);

    //怎样动需要QTimeLiness函数
    QTimeLine *timeline = new QTimeLine();      //持续三秒钟
    timeline->setLoopCount(NULL);                      //设置循环次数

    animation->setTimeLine(timeline);
    //animation->rotationAt(45);                      //以怎样的角度进行旋转
    animation->setTranslationAt(1, 200, 200);

    timeline->start();

    _timer = new QTimer();
    _timer->setInterval(1000);       //设置间隔时间
    connect(_timer, SIGNAL(timeout()), this, SLOT(slotTimeOut()));
    _timer->start();


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM