How to create custom text animation (glyph) by Qt

I want to do dynamic text animation with Qt for Arabic and Persian texts? Could you help me? You can see an example of what I need.

Target selection enter image description here

wrong sample enter image description here

+4
source share
1 answer

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(); 
+3
source

Source: https://habr.com/ru/post/1484846/


All Articles