zoukankan      html  css  js  c++  java
  • Qt开发动画

    #include <QPropertyAnimation>

    #include <QDesktopWidget>

    //下坠

    void MainWindow::on_pushButton_clicked()

    {

    QPropertyAnimation *pAnimation = new QPropertyAnimation(this, "geometry");

    QDesktopWidget *pDesktopWidget = QApplication::desktop();

    int x = (pDesktopWidget->availableGeometry().width() - width()) / 2;

    int y = (pDesktopWidget->availableGeometry().height() - height()) / 2;

    pAnimation->setDuration(1000);

    pAnimation->setStartValue(QRect(x, 0, width(), height()));

    pAnimation->setEndValue(QRect(x, y, width(), height()));

    pAnimation->setEasingCurve(QEasingCurve::OutElastic);

    pAnimation->start(QAbstractAnimation::DeleteWhenStopped);

    }

    //抖动

    void MainWindow::on_pushButton_2_clicked()

    {

    QPropertyAnimation *pAnimation = new QPropertyAnimation(this, "pos");

    pAnimation->setDuration(500);

    pAnimation->setLoopCount(2);

    pAnimation->setKeyValueAt(0, QPoint(geometry().x() - 3, geometry().y() - 3));

    pAnimation->setKeyValueAt(0.1, QPoint(geometry().x() + 6, geometry().y() + 6));

    pAnimation->setKeyValueAt(0.2, QPoint(geometry().x() - 6, geometry().y() + 6));

    pAnimation->setKeyValueAt(0.3, QPoint(geometry().x() + 6, geometry().y() - 6));

    pAnimation->setKeyValueAt(0.4, QPoint(geometry().x() - 6, geometry().y() - 6));

    pAnimation->setKeyValueAt(0.5, QPoint(geometry().x() + 6, geometry().y() + 6));

    pAnimation->setKeyValueAt(0.6, QPoint(geometry().x() - 6, geometry().y() + 6));

    pAnimation->setKeyValueAt(0.7, QPoint(geometry().x() + 6, geometry().y() - 6));

    pAnimation->setKeyValueAt(0.8, QPoint(geometry().x() - 6, geometry().y() - 6));

    pAnimation->setKeyValueAt(0.9, QPoint(geometry().x() + 6, geometry().y() + 6));

    pAnimation->setKeyValueAt(1, QPoint(geometry().x() - 3, geometry().y() - 3));

    pAnimation->start(QAbstractAnimation::DeleteWhenStopped);

    }

    //透明度变化

    void MainWindow::on_pushButton_3_clicked()

    {

    QPropertyAnimation *pAnimation = new QPropertyAnimation(this, "windowOpacity");

    pAnimation->setDuration(1000);

    pAnimation->setKeyValueAt(0, 1);

    pAnimation->setKeyValueAt(0.5, 0);

    pAnimation->setKeyValueAt(1, 1);

    pAnimation->start(QAbstractAnimation::DeleteWhenStopped);

    }

    转自:http://blog.csdn.net/liang19890820/article/details/51888114

    //逐渐出现

    QPropertyAnimation *animation = new QPropertyAnimation(this, "windowOpacity");
    animation->setDuration(1000);
    animation->setStartValue(0);
    animation->setEndValue(1);
    animation->start();

    以上均为窗口动画。

    控件动画:【均未成功,不知为何】

    1、

    QPropertyAnimation *pAnimation = new QPropertyAnimation(ui.groupBox, "opacity");
    pAnimation->setDuration(1000);
    pAnimation->setStartValue(0);
    pAnimation->setEndValue(1);
    pAnimation->start(QAbstractAnimation::DeleteWhenStopped);

    2、

    QGraphicsOpacityEffect* effect = new QGraphicsOpacityEffect(ui.label);
    effect->setOpacity(1);
    ui.label->setGraphicsEffect(effect);
    QPropertyAnimation *pAnimation = new QPropertyAnimation(effect, "opacity",this);
    pAnimation->setEasingCurve(QEasingCurve::Linear);
    pAnimation->setDuration(10000);
    pAnimation->setStartValue(1);
    pAnimation->setEndValue(0);
    pAnimation->start(QAbstractAnimation::KeepWhenStopped);
    delete effect;
    delete pAnimation;

  • 相关阅读:
    uniapp 的组件 定义了 直接使用即可 。
    uniapp 关闭微信小程序的索引警告
    微信小程序 组件化开发 实现 导航分类文章 小程序
    微信小程序 向下滚动加载更多 和 上滑刷新的写法
    微信小程序 用 Pormise 封装 wx.request 请求
    ES6 再次学习 Promise语法(代码图解)
    Maven依赖排除及版本统一
    Maven依赖使用的范围
    SSM整合时的配置文件
    SSM整合时用到的maven依赖
  • 原文地址:https://www.cnblogs.com/judes/p/7016316.html
Copyright © 2011-2022 走看看