QPropertyAnimation属性动画不动作
槽函数已经运行,但是属性动画就是没反应,系统也不报错
#include "mypushbutton.h"
#include<QPainter>
#include<QPropertyAnimation>
//#include<QAbstractAnimation>
#include<QDebug>
MyPushbutton::MyPushbutton(QWidget *parent)
: QPushButton{parent}
{
}
void MyPushbutton::moveDown()
{
//qdebug测试槽函数lambda已经成立,动画出了问题
qDebug()<<"动画"<<Qt::endl;
QPropertyAnimation *animation = new QPropertyAnimation(this,"geometry",this);
animation->setStartValue(this->geometry());
animation->setEndValue(QRect(this->x(),(this->y()+10),this->width(),this->height()));
animation->setDuration(100);
animation->state();
}
运行debug内容输出,但是动画效果没有
刚开始以为connect出了问题,添加debug以后控制台可以输出,说明connect没问题。
还有就是在 animation->state(QAbstractAnimation::DeleteWhenStopped);给start加上这个结束后删除对象的内容后报错:
mypushbutton.cpp:25:22: Too many arguments to function call, expected 0, have 1
qabstractanimation.h:54:11: 'state' declared here