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();