I suggest using the following classes: QGraphicsScene and QGraphicsView to process and display your graphics; QGraphicsTextItem to display each character; QGraphicsItemAnimation to animate characters.
I donโt know how exactly the example you published and what transformations apply. I wrote a simple example. Here, the initial rotation and translation of each element are set randomly, and the final positions have no 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();
source share