Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to wait until QPropertyAnimation finishes?
Qt 6.12 LTS is out! See what's new in the release blog

How to wait until QPropertyAnimation finishes?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 11.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi all

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

    Thanks ahead
    Vlad

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alexander
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            ??
            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?

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt
            • Unsolved