qt中,翻金币小案例,我想封装一个函数(获胜的图片弹出的特效),然后在类内调用,显示不出来

封装的函数如下:


//胜利图片显示
void PlayScene::showAll()
{
    qDebug()<<"有没有呀";
    QLabel *winlabel=new QLabel;
    QPixmap pix;
    pix.load(":/res/LevelCompletedDialogBg.png");
    winlabel->setGeometry(0,0,pix.width(),pix.height());
    winlabel->setPixmap(pix);
    winlabel->setParent(this);
    winlabel->move((this->width()-pix.width())*0.5, -pix.height());

    //将胜利的图片移动下来
    QPropertyAnimation *animation=new QPropertyAnimation(winlabel,"geometry");
    //设置时间的间隔
    animation->setDuration(1000);
    //设置开始位置
    animation->setStartValue(QRect(winlabel->x(),winlabel->y(),winlabel->width(),winlabel->height()));
    //设置结束位置
    animation->setEndValue(QRect(winlabel->x(),winlabel->y()+114,winlabel->width(),winlabel->height()));
    //设置缓和曲线
    animation->setEasingCurve(QEasingCurve::OutBounce);
    //开始
    animation->start();
    qDebug()<<"you";
}

当我将这个函数放到构造函数中,可以弹出,但是他一开始就直接弹出来了,我想放到,金币全部翻到的封装函数下面,如下

PlayScene::PlayScene(int levelNum)
{
this->showAll();
}

这是还有银币的时候直接弹出来了,相当于构造函数直接初始化了

img


然后我放到判断胜利的函数下边:

void PlayScene::transCoin(int (*gameArray)[4],MyCoin *coinBtn[4][4], MyCoin *const coin)

{
        if(this->allNum==16)
        {
            qDebug()<<"胜利了";
          this->showAll();
            //将所有的按钮
            for(int i=-0;i<4;i++)
            {
                for(int j=0;j<4;j++)
                {
                    //this->coinBtn[i][j]->disconnect();
                    this->coinBtn[i][j]->isWin=true;
                }
            }

        }

}

然后怎么都不弹出来那个图片,我怀疑是下面这句代码的问题,但是我不知道咋改!

winlabel->setParent(this);

winlabel->setParent(this);这句不要
加上winlabel->show();