【问题标题】:Fast animation for showing semi-transparent circle显示半透明圆圈的快速动画
【发布时间】:2014-08-03 07:39:27
【问题描述】:

我正在使用 Qt for Android 开发一个简单的测试应用程序。我试图通过显示半透明的圆圈来为屏幕上的每个用户触摸设置动画,例如将其半径从 0 增加到 100。

我在所有小部件之上添加了一个自定义 QLabel。我正在尝试通过使用自定义属性的 QPropertyAnimation 对其 QPixmap 进行更新来为其 QPixmap 设置动画

Q_PROPERTY(QRect circleGeometry READ getCircleGeometry WRITE setCircleGeometry)

二传手是:

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);
}

我明白了,setter 对于动画来说太重了,所以它在我的 android 设备上运行缓慢。 您能否建议我如何修改我的动画以使其快速流畅。

【问题讨论】:

    标签: android c++ qt animation qt5


    【解决方案1】:

    所以...我的解决方案是在应用程序启动时创建一个 QPixmaps 向量,然后我的 CircleLabel::setCircleGeometry 将如下所示:

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

    【讨论】:

      猜你喜欢
      • 2022-01-26
      • 1970-01-01
      • 2021-06-10
      • 2012-10-30
      • 1970-01-01
      • 1970-01-01
      • 2017-03-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多