//头文件声明animation
QPropertyAnimation *animation
//cpp类文件里实现,50ms后执行slot showout()
animation = new QPropertyAnimation(this, "geometry");
animation->setDuration(1000);
QTimer::singleShot(50,this,SLOT(showOut()));
//showOut的实现:
void showOut()
{
show();
move(deskRect.width() / 2 - width() / 2, 0-height()); //移动到中间,上面,隐藏。
animation->setStartValue(QRect(deskRect.width() / 2 - width() / 2,0-height(),width(),height())); //起始位置
animation->setEndValue(QRect(deskRect.width() / 2 - width() / 2,0,width(),height()));
animation->start(); //终止位置
}
好使不,达到你的意图了没?欢迎留言