qt animation动画

QPropertyAnimation *animation = new QPropertyAnimation(this,"geometry",this);// 属性geometry(包含x,y坐标和宽w高h坐标)
animation->setDuration(100); //动画时长100毫秒
animation->setStartValue(this->geometry()); //设置起始位置,就用当前位置
animation->setEndValue(QRect(this->x(),this->y()+10,this->width(),this->height()));

案例二

    QLabel* labeWin = new QLabel(this);
    QPixmap pix(":/res/LevelCompletedDialogBg.png");
    labeWin->setPixmap(pix);
    labeWin->resize(pix.size());
    labeWin->move(this->width()/2-labeWin->width()/2,-labeWin->height());
    labeWin->show();
    QPropertyAnimation* animation = new QPropertyAnimation(labeWin,"geometry",this);
    animation->setStartValue(labeWin->geometry());
    animation->setEndValue(QRect(labeWin->x(),labeWin->y()+100,labeWin->width(),labeWin->height()));
    animation->setDuration(1000);
    // 设置动画的运动曲线
    animation->setEasingCurve(QEasingCurve::OutBounce);
    // 动画播放完自动删除
    animation->start(QAbstractAnimation::DeleteWhenStopped);

posted on 2021-05-20 14:26  lodger47  阅读(393)  评论(0)    收藏  举报

导航