Dear Everyone!

I am animating text using QTimeline & QGraphicsItem Class. I am facing problem of varing velocity (speed of text) of text if text size is not equal for multiple animation. I want to constant velocity (animation speed constant) for variable length text. What can I do for this.

I am putting the code for that....
Qt Code:
  1. QGraphicsTextItem *scrItem = new QGraphicsTextItem(txtScrollEdit->toPlainText());
  2. QDir::setCurrent(QDir::currentPath ()+"/media");
  3.  
  4. scrItem->setDefaultTextColor(Qt::red);
  5. scene->setBackgroundBrush(Qt::yellow);
  6.  
  7.  
  8.  
  9. animation->setItem(scrItem);
  10.  
  11.  
  12. float n;
  13. view=new QGraphicsView(scene,btgScrollText);
  14. view->setWindowFlags (Qt::FramelessWindowHint);
  15.  
  16. scene->addItem(scrItem);
  17.  
  18. view->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
  19. view->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
  20. view->setCacheMode(QGraphicsView::CacheBackground);
  21.  
  22. n=355; /*Width of txtScrollEdit TextEdit*/
  23.  
  24. qreal h=scene->height()/2-scrItem->boundingRect().height()/2;
  25.  
  26.  
  27. register int velocity=40;
  28. register int tl=n*velocity;
  29.  
  30. timer = new QTimeLine(tl);
  31.  
  32.  
  33. timer->setCurveShape(QTimeLine::LinearCurve);
  34. timer->setLoopCount(0);
  35. animation->setTimeLine(timer);
  36. animation1->setTimeLine(timer);
  37.  
  38.  
  39. register int scrItembrw=scrItem->boundingRect().width();
  40. for (register int i=0; i<(n+scrItembrw); i=i+1)
  41. {
  42. register QPointF p(0,h); //sets the position of scrItem
  43. p.setX(n-i);
  44. p.setY(h);
  45. animation->setPosAt(i/(n+scrItembrw),p);
  46.  
  47. }//end for
  48.  
  49. view->show();
  50. timer->start();
To copy to clipboard, switch view to plain text mode 
Thanks in Advance!