Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Uncknowed Delay in Fade in/ou animation with QPropertyAnimation
Qt 6.12 LTS is out! See what's new in the release blog

Uncknowed Delay in Fade in/ou animation with QPropertyAnimation

Scheduled Pinned Locked Moved Unsolved General and Desktop
18 Posts 4 Posters 3.2k Views 2 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.
  • J jawad_soft

    @eyllanesc i'm trying to use QSequentialAnimationGroup but i don't now how integrate it, can you give me exemple with my animations ?

    mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #8

    hi
    Look here
    https://evileg.com/en/post/423/

    Bascially you can just add what you have to the group
    animationGroup->addAnimation(fadeEffect );

    and then use
    https://doc.qt.io/qt-5/qsequentialanimationgroup.html#addPause
    in to add pause in between between

    1 Reply Last reply
    0
    • J jawad_soft

      @eyllanesc i'm trying to use QSequentialAnimationGroup but i don't now how integrate it, can you give me exemple with my animations ?

      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by eyllanesc
      #9

      @jawad_soft example:

          QGraphicsOpacityEffect *fadeEffect = new QGraphicsOpacityEffect(this);
          m_ui->ui_graphicsView->setGraphicsEffect(fadeEffect);
      
          QPropertyAnimation *anim1 = new QPropertyAnimation(fadeEffect, "opacity");
          anim1->setDuration(7000);
          anim1->setStartValue(0.0);
          anim1->setEndValue(1.0);
          anim1->setEasingCurve(QEasingCurve::InBack);
      
          QPropertyAnimation *anim2 = new QPropertyAnimation(fadeEffect, "opacity");
          anim2->setDuration(7000);
          anim2->setStartValue(1.0);
          anim2->setEndValue(0.0);
          anim2->setEasingCurve(QEasingCurve::OutBack);
      
          QSequentialAnimationGroup *group = new QSequentialAnimationGroup;
          group->addAnimation(anim1);
          group->addAnimation(anim2);
          group->start(QPropertyAnimation::DeleteWhenStopped);
      

      Side note: If you want to display images in QGraphicsView IMO it is better to use a single QGraphicsPixmapItem and then switch QPixmaps when necessary.

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      1 Reply Last reply
      1
      • J Offline
        J Offline
        jawad_soft
        wrote on last edited by
        #10

        @eyllanesc said in Uncknowed Delay in Fade in/ou animation with QPropertyAnimation:

        QSequentialAnimationGroup

        @mrjj @eyllanesc ,

        Even with QSequentialAnimationGroup , any animation are blocked with the duration that i chose, it's switch directly to next diplayed think i have in my app, this is why i have used "Delay_MSec(7000);" and also after every "fade out animation " i have to disable one qlabel and activate another !!!

        I never use QGraphicsPixmapItem !!

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #11

          hi
          but for the same effect as
          Delay_MSec(7000);
          you need to use the addPause

          Did you do that ?

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jawad_soft
            wrote on last edited by
            #12

            @mrjj @eyllanesc

            The addPause doesn't change anything, the animation style none blocking and the delay are always present bettwen each animation!

                                fadeEffect = new QGraphicsOpacityEffect(this);
                                m_ui->ui_graphicsView->setGraphicsEffect(fadeEffect);   
                           
                                // ****************************  logo fade in*******************************
                                animLogo0 = new QPropertyAnimation(fadeEffect,"opacity");
                                animLogo0->setDuration(8000);
                                animLogo0->setStartValue(0.0);
                                animLogo0->setEndValue(1.0);
                                animLogo0->setEasingCurve(QEasingCurve::InBack);
            
            
                                // ****************************  logo fade out*******************************
                
                                animLogo1 = new QPropertyAnimation(fadeEffect,"opacity");
                                animLogo1->setDuration(8000);
                                animLogo1->setStartValue(0.0);
                                animLogo1->setEndValue(1.0);
                                animLogo1->setEasingCurve(QEasingCurve::OutBack);
            
                                // ****************************  logo fade in*******************************
            
                                animLogo2 = new QPropertyAnimation(fadeEffect,"opacity");
                                animLogo2->setDuration(8000);
                                animLogo2->setStartValue(0.0);
                                animLogo2->setEndValue(1.0);
                                animLogo2->setEasingCurve(QEasingCurve::InBack);
            
            
                                // ****************************  logo fade out*******************************
            
                                animLogo3 = new QPropertyAnimation(fadeEffect,"opacity");
                                animLogo3->setDuration(8000);
                                animLogo3->setStartValue(1.0);
                                animLogo3->setEndValue(0);
                                animLogo3->setEasingCurve(QEasingCurve::OutBack);
            
            
                                group->addAnimation(animLogo0);
                                group->addPause(8000);
                                group->addAnimation(animLogo1);
                                group->addPause(8000);
                                group->addAnimation(animLogo2);
                                group->addPause(8000);
                                group->addAnimation(animLogo3);
                                group->addPause(8000);
                                group->start(QPropertyAnimation::DeleteWhenStopped);
            
                               QTextStream(stdout) <<"Animation End"<< endl;
            

            I try also to put all the group->addPause(8000) => group->addPause(100) but that not block anything !
            the " QTextStream(stdout) <<"Animation End"<< endl;" should be executed after the end of all animation, but it's not what happen

            mrjjM 1 Reply Last reply
            0
            • J jawad_soft

              @mrjj @eyllanesc

              The addPause doesn't change anything, the animation style none blocking and the delay are always present bettwen each animation!

                                  fadeEffect = new QGraphicsOpacityEffect(this);
                                  m_ui->ui_graphicsView->setGraphicsEffect(fadeEffect);   
                             
                                  // ****************************  logo fade in*******************************
                                  animLogo0 = new QPropertyAnimation(fadeEffect,"opacity");
                                  animLogo0->setDuration(8000);
                                  animLogo0->setStartValue(0.0);
                                  animLogo0->setEndValue(1.0);
                                  animLogo0->setEasingCurve(QEasingCurve::InBack);
              
              
                                  // ****************************  logo fade out*******************************
                  
                                  animLogo1 = new QPropertyAnimation(fadeEffect,"opacity");
                                  animLogo1->setDuration(8000);
                                  animLogo1->setStartValue(0.0);
                                  animLogo1->setEndValue(1.0);
                                  animLogo1->setEasingCurve(QEasingCurve::OutBack);
              
                                  // ****************************  logo fade in*******************************
              
                                  animLogo2 = new QPropertyAnimation(fadeEffect,"opacity");
                                  animLogo2->setDuration(8000);
                                  animLogo2->setStartValue(0.0);
                                  animLogo2->setEndValue(1.0);
                                  animLogo2->setEasingCurve(QEasingCurve::InBack);
              
              
                                  // ****************************  logo fade out*******************************
              
                                  animLogo3 = new QPropertyAnimation(fadeEffect,"opacity");
                                  animLogo3->setDuration(8000);
                                  animLogo3->setStartValue(1.0);
                                  animLogo3->setEndValue(0);
                                  animLogo3->setEasingCurve(QEasingCurve::OutBack);
              
              
                                  group->addAnimation(animLogo0);
                                  group->addPause(8000);
                                  group->addAnimation(animLogo1);
                                  group->addPause(8000);
                                  group->addAnimation(animLogo2);
                                  group->addPause(8000);
                                  group->addAnimation(animLogo3);
                                  group->addPause(8000);
                                  group->start(QPropertyAnimation::DeleteWhenStopped);
              
                                 QTextStream(stdout) <<"Animation End"<< endl;
              

              I try also to put all the group->addPause(8000) => group->addPause(100) but that not block anything !
              the " QTextStream(stdout) <<"Animation End"<< endl;" should be executed after the end of all animation, but it's not what happen

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #13

              @jawad_soft
              Hi
              well it won't block anything (as blocking is bad in event-driven apps)
              but should run them in order.

              Yes "Animation End" will show at once as they
              do not block and its expected to use signal and slot
              for such things.

              Are you saying that addPause Does not add a pause between the animations ?

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jawad_soft
                wrote on last edited by jawad_soft
                #14

                @mrjj ,

                My fault, the addPause add effectively a pause between the animations, but the dealy are alway present !

                I decide to use QAbstractAnimation::finished signal and private slots for every animation to debug the problem and understand exactly when the delay that i want to remove are present, and it's appear that this delay are present in the end of every animation, maybe because i'm increasing/ decresing opacity of the widget and it's take to long time to get opacity(0) maybe. there is any function that make me to dispaly the actual opacity of the widget ?

                Thanks again for your support !

                mrjjM 1 Reply Last reply
                0
                • J jawad_soft

                  @mrjj ,

                  My fault, the addPause add effectively a pause between the animations, but the dealy are alway present !

                  I decide to use QAbstractAnimation::finished signal and private slots for every animation to debug the problem and understand exactly when the delay that i want to remove are present, and it's appear that this delay are present in the end of every animation, maybe because i'm increasing/ decresing opacity of the widget and it's take to long time to get opacity(0) maybe. there is any function that make me to dispaly the actual opacity of the widget ?

                  Thanks again for your support !

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #15

                  @jawad_soft
                  Hi
                  Good work.
                  There is only the getter for opacity and I'm pretty sure it will report the value you just set.

                  if you make the span less 1.0 -> 0.5
                  does this pause till happens?

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    jawad_soft
                    wrote on last edited by jawad_soft
                    #16

                    yeah i try this trick ! and the opacity of the widget pause on 0.5 i think, but still the delay present ! maybe playing with the opacity of all the widget is not good idea !

                    My goal is simple ! fade in/ou two image in the beging of my app, but it's morte complicated that it's appear hahaha

                    i creat timer slot that print in the actual opacity every 20Ms, and it's look like good, it's increas/decreas normally

                    1 Reply Last reply
                    0
                    • Chris KawaC Offline
                      Chris KawaC Offline
                      Chris Kawa
                      Lifetime Qt Champion
                      wrote on last edited by Chris Kawa
                      #17

                      There was a similar question recently where someone wanted to animate a gif in a graphics item. Like there - using widgets for animation, much so with their opacity, is a very heavy thing to do.
                      A much simpler approach is to make a custom graphics item that just uses painter to draw two images over each other using setOpacity().
                      You can use QTimeline to animate it and repaint on its frameChanged signal.

                      Here's the custom class that draws gif: https://forum.qt.io/topic/123784/animated-gif-in-qgraphicsscene-qgraphicsview/4
                      Should be easy enough to change to drawing two images with a timeline.

                      J 1 Reply Last reply
                      3
                      • Chris KawaC Chris Kawa

                        There was a similar question recently where someone wanted to animate a gif in a graphics item. Like there - using widgets for animation, much so with their opacity, is a very heavy thing to do.
                        A much simpler approach is to make a custom graphics item that just uses painter to draw two images over each other using setOpacity().
                        You can use QTimeline to animate it and repaint on its frameChanged signal.

                        Here's the custom class that draws gif: https://forum.qt.io/topic/123784/animated-gif-in-qgraphicsscene-qgraphicsview/4
                        Should be easy enough to change to drawing two images with a timeline.

                        J Offline
                        J Offline
                        jawad_soft
                        wrote on last edited by
                        #18

                        @Chris-Kawa Thanks for suggestion , i will try this !

                        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