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