检查QVariantAnimation是否完成?

时间:2013-08-22 14:15:57

标签: c++ qt animation signals slot

我有一个派生自QVariantAnimation的类,我必须在动画结束后运行代码。

我尝试了信号finished(),但没有发射:

connect(this, SIGNAL(finished()), this, SLOT(setEndVariables()));

有没有其他意见可以看动画是否停止,或信号的使用是否错误?

编辑:使用代码

LiConfigurableFrameAnimation::LiConfigurableFrameAnimation(QString compId, int dur, LiConfigurableFrame *f)
{
    if(dur>0)
        this->setDuration(dur);
    frame=f;
    widget=frame->getComponent(compId);
    isRectMode=false;
    isImageMode=false;

    connect(this, SIGNAL(finished()), this, SLOT(setEndVariables()));
}

标题文件:

class LiConfigurableFrameAnimation: public QVariantAnimation
{

    private slots:
        void setEndVariables();

    };

1 个答案:

答案 0 :(得分:0)

我解决了这个问题:

我重载函数updateCurrentTime并检查当前时间是否等于持续时间。

updateCurrentTime(int curr)
{

    if(curr >= this->duration())....
... 
相关问题