噯貘 2022-12-31 23:12 采纳率: 100%
浏览 95
已结题

QPropertyAnimation属性动画不运行,

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

实在麻爪了,求指点!
  • 写回答

1条回答 默认 最新

  • heart_6662 2022-12-31 23:26
    关注

    望采纳!!点击该回答右侧的“采纳”按钮即可采纳!!我现在写给你

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 1月9日
  • 已采纳回答 1月1日
  • 创建了问题 12月31日

悬赏问题

  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败