//QPropertyAnimation动画类
//用动画设置窗口透明度
QPropertyAnimation *animation = new QPropertyAnimation(this, “windowOpacity”);
animation->setDuration(3000); //动画历时 动画出现多长时间结束
animation->setStartValue(0); //设置起始值
animation->setEndValue(1); //设置结束值
animation->start();//开启动画
//用动画设置窗口的移动
QPropertyAnimation *animation = new QPropertyAnimation(this, "pos");// 设置窗口这个属性的动画
//animation->setDuration(3000); //动画事件
animation->setStartValue(QPoint(-100, -100));//开始为止
animation->setEndValue(QPoint(500, 100));//结束位置
animation->setEasingCurve(QEasingCurve::Linear);
connect(animation, SIGNAL(finished()), this, SLOT(xxx())); //动画结束后需要执行的函数
animation->start();
本文介绍了如何使用QPropertyAnimation类来实现窗口透明度变化及移动的动画效果。通过设置动画时长、起始值、结束值及缓动曲线,演示了动画在Qt应用中的具体实现。
1690

被折叠的 条评论
为什么被折叠?



