当用户点击显示对话框时,是否有任何方法可以添加对话框从最小尺寸到最大尺寸的效果! 就像在我们请求打开对话框的iphoto一样,它以同样的方式出现! 我正在使用的代码是:
fade_effect = new QGraphicsOpacityEffect(this);
this->setGraphicsEffect(fade_effect);
animation = new QPropertyAnimation(fade_effect, "opacity");
animation->setEasingCurve(QEasingCurve::InOutQuad);
animation->setDuration(5000);
animation->setStartValue(1);
animation->setEndValue(0.01);
animation->start(QPropertyAnimation::DeleteWhenStopped);
this->setWindowOpacity(0.5);
//this->hide();
//QDialog::reject();
它没有隐藏案例。
答案 0 :(得分:1)
Qt Animation Framework为您提供了许多创建动画效果的工具。以下是使用QPropetyAnimation
:
void YourWindowClass::showEvent(QShowEvent* e)
{
//create animation for "geometry" property
QPropertyAnimation *animation = new QPropertyAnimation(this, "geometry");
//duration in ms
animation->setDuration(500);
//starting geometry
QRect startRect(900,500,100,100);
//final geometry
QRect endRect(750,350,400,400);
animation->setStartValue(startRect);
animation->setEndValue(endRect);
//starts animation which will be deleted when finished
animation->start(QAbstractAnimation::DeleteWhenStopped);
}