Quick animation to show a semi-transparent circle

I am developing a simple test app with Qt for Android. I'm trying to animate each user on the screen by showing a semi-transparent circle that increases their radius from 0 to 100, for example.

I added a custom QLabel on top of all the widgets. And I am trying to animate his QPixmap by updating it with QPropertyAnimation for a custom property

Q_PROPERTY(QRect circleGeometry READ getCircleGeometry WRITE setCircleGeometry)

      

Installer:

void CircleLabel::setCircleGeometry(QRect circleGeometry)
{
    QPixmap pixmap(this->size());
    pixmap.fill(Qt::transparent);

    QPainter painter(&pixmap);
    painter.setOpacity(0.2);
    painter.setPen(QPen(Qt::transparent));
    painter.setBrush(QBrush(Qt::white));
    painter.setRenderHint(QPainter::Antialiasing);

    painter.drawEllipse(circleGeometry);

    this->setPixmap(pixmap);
}

      

I see that the setter is too heavy to animate, so it is slow on my android device. Could you please advise me how I can change my animation to make it fast and smooth.

+3


source to share


1 answer


So ... My solution to create a QPixmaps vector once, on application startup, and then my CircleLabel :: setCircleGeometry would look like this:



void CircleLabel::setCircleGeometry(int currentIdx)
{
    this->setPixmap(preGeneratedPixmaps[currentIdx]);
}

      

0


source







All Articles