Sequential animations seem to start early

  • I have an animation that changes the size of a widget. Because it is a widget contained in a dockwidget, I grow it by changing the minimumSize then reset its minimumSize to 0,0. I use a QSequentialAnimationGroup for these two changes, however when the duration of the second animation is short, the widget does not grow all the way to specified size. It appears that the second animation starts before the first one finishes. Here is the code:

    @ QSequentialAnimationGroup* seqGroup = new QSequentialAnimationGroup();

    QPropertyAnimation* anim = new QPropertyAnimation(widget(), "minimumHeight");
    QPropertyAnimation* defixMaxSize = new QPropertyAnimation(widget(), "maximumSize");
    QPropertyAnimation* defixMinSize = new QPropertyAnimation(widget(), "minimumSize");

    When the duration of the second two animations are 1, the widget does not grow all the way to "height", if the duration is changed to 10, they seem much more likely to. Can anybody clue me into why this is happening?

  • I'm not sure, but a duration value of 1 means 1ms. Since the second animation start immediately after the first one finishes, maybe you're just not noticing that it grew completely. You could also try to "add a pause": .

  • A pause of 1 ms did not help. Thanks for the suggestion. I realize that 1 ms is short, but the widget does not reach the end value of the first animation when the whole animation sequence finishes.

  • Moderators

    Just as a test, have you tried using longer durations (say 250ms each) for each of the animations? Starting with larger numbers then reducing the duration down may give some insight to the operation of the sequential animation and how its interacting with the individual animations. There may be a floor value where things don't behave quite right because of the resolution of the system timers.

Log in to reply

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