How to wait until QPropertyAnimation finishes?



  • Hi all

    How can I pause executing program until QPropertyAnimation will finish its work?

    Thanks ahead
    Vlad



  • Why do not you want to do another actions async. when get signal @finished()@ from QPropertyAnimation



  • Please, explain why you want to do that. Maybe you're trying to solve a problem with a wrong solution...

    Well, QPropertyAnimaion uses timers to do its job, so you can't just block qt's main loop or you will not see your animation.

    I would suggest to connect the signal "stateChanged":http://doc.trolltech.com/4.6/qabstractanimation.html#stateChanged in your app and detect when your animation starts and when it finishes. With this approach, you can block the components that shouldn't react during the animation.



  • Yes, you are rigth. I just forget I could block component from receiving new events and starting the same animation again. Thanks.



  • ??
    hello all,i use a for loop to move 10 QToolButtons one by one,but they move together in the end,and i don't know why.

    /*

    for loop
    */
    for(int i=1;i<=3;i++){
    serialBin = score(temp,x);//Assign a value
    serialNumber = i-1;//Assign a value
    emit mySignal2();//signal
    QThread::sleep(1);
    }

    /*
    Some of the variables and the statement
    /
    QToolButton
    theCounts[10];
    QPropertyAnimation* theAnimation[10];
    QSignalMapper *m_pSignalMapper;
    ......

    connect(this,SIGNAL(mySignal2()),theCounts[serialNumber],SIGNAL(clicked()));
    connect(theCounts[serialNumber], SIGNAL(clicked()), m_pSignalMapper, SLOT(map()));
    m_pSignalMapper->setMapping(theCounts[serialNumber], QEasingCurve::OutSine);
    
    connect(m_pSignalMapper, SIGNAL(mapped(int)),this, SLOT(SetAnimation(int)));
    

    /*
    the SetAnimation function
    */
    void MainWindow::SetAnimation(int nCurveType)
    {
    qDebug() << "serialNumber = " << serialNumber;
    if(theAnimation[serialNumber]->state()==QPropertyAnimation::Running)
    {
    theAnimation[serialNumber]->stop();
    }

    theAnimation[serialNumber]->setDuration(1000);//持续时间
    theAnimation[serialNumber]->setStartValue(QRect(serialNumber*40,20, 40, 40));
    theAnimation[serialNumber]->setEndValue(QRect(width()-400+serialBin*40,height()/2+40,40,40));
    theAnimation[serialNumber]->setEasingCurve(QEasingCurve::Type(nCurveType));
    theAnimation[serialNumber]->start();
    theAnimation[serialNumber]->f
    

    }

    because the whole project is too large,i don't copy all.
    Who can tell me why?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.