4

I want to make a dynamic text animation with Qt for arabic and persian texts?can you help me? You can see an example of what i need.

Trust sample enter image description here

wrong sample enter image description here

khani_mahdi
  • 166
  • 9
  • I can make an animation but in arabic and persian texts the letters are separated.some programmer suggested me to use glyph but I dont know how I should do that – khani_mahdi Jun 07 '13 at 06:28

1 Answers1

3

I suggest to use the following classes: QGraphicsScene and QGraphicsView to handle and display your graphics, QGraphicsTextItem to display each character, QGraphicsItemAnimation to animate characters.

I do not know how exactly acts the example you've posted and which transformations are applied. I wrote a simple example. Here the initial rotation and translation of each item is set randomly, and the final positions are without any transformation.

QString text = "test";
int current_width = 0;
QFont font("", 30);
QTimeLine *timeline = new QTimeLine(2000);
foreach(QChar c, text) {
  QGraphicsTextItem* item = scene.addText(c);
  item->setFont(font);
  item->adjustSize();
  item->setPos(current_width, 0);
  current_width += item->textWidth();
  QGraphicsItemAnimation *animation = new QGraphicsItemAnimation;
  animation->setItem(item);
  animation->setTimeLine(timeline);
  animation->setRotationAt(0, 360.0 * rand() / RAND_MAX);
  animation->setTranslationAt(0, 100 * rand() / RAND_MAX,
                                 100 * rand() / RAND_MAX);
  animation->setRotationAt(1, 0);
  animation->setTranslationAt(1, 0, 0);
}
ui.graphicsView->setScene(&scene);
timeline->start();
Pavel Strakhov
  • 39,123
  • 5
  • 88
  • 127