2016-11-24 138 views
0
QGraphicsBubbleItem::QGraphicsBubbleItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parentItem) 
    : QGraphicsEllipseItem(x, y, width, height, parentItem) 
{ 
    timer = new QTimeLine(3000); 
    timer->setFrameRange(0, 100); 
    //timer->setLoopCount(3); 
    connect(timer, &QTimeLine::finished, timer, &QTimeLine::start); 

    animation = new QGraphicsItemAnimation; 
    animation->setItem(this); 
    animation->setTimeLine(timer); 

    animation->setTranslationAt(0, (width/2)*(-1), (height/2)*(-1)); 
    animation->setRotationAt(0.5, 180); 
    animation->setRotationAt(1, 360); 

    timer->start(); 
} 

還有更多的動畫,但我已將代碼簡化爲顯示問題的位。項目被繪製並且正在旋轉,但它在每個循環後的可見時刻停止。QGraphicsItemAnimation在每個QTimeLine循環後暫停

回答

0

默認情況下,QTimeLine使用曲線設置爲:

QTimeLine::EaseInOutCurve 

指價值開始慢慢成長,然後運行穩定,然後再慢慢地增長。嘗試setting the curve shape線性:

QTimeLine::LinearCurve 
+0

謝謝,我不知道我怎麼會在文檔中錯過了... – smsware