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