QPushButton *btn = new QPushButton("Button", this);
btn->setGeometry(10, 10, 100, 30);
QPropertyAnimation *animation;
animation = new QPropertyAnimation(btn, "geometry", this);
animation->setDuration(3000);//從起始坐标到結束坐标的時長[機關ms]3s,預設250ms
animation->setStartValue(QRect(10, 10, 100, 30)); //設定起始坐标
animation->setEndValue(QRect(200, 150, 100, 30)); //結束坐标,當坐标值改變時,會發生valueChanged信号事件
animation->start();

版權聲明:本文為CSDN部落客「weixin_34408717」的原創文章,遵循CC 4.0 BY-SA版權協定,轉載請附上原文出處連結及本聲明。
原文連結:https://blog.csdn.net/weixin_34408717/article/details/92420811