Results 1 to 3 of 3

Thread: QSequentialAnimationGroup don't seems to start all animations

  1. #1
    Join Date
    Jul 2011
    Location
    Brasil
    Posts
    39
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QSequentialAnimationGroup don't seems to start all animations

    Hi all,

    I'm trying to animate my QMainWindow subclasses every time them get showed.
    For that I wrote the following:
    Qt Code:
    1. void Loader_mainWindow::showEvent(QShowEvent * ){
    2. ui->centralWidget->hide(); //hide everything inside to improve speed
    3. QPropertyAnimation * pa=new QPropertyAnimation();
    4. pa->setDuration(1000);
    5. pa->setStartValue(QRect(0,0,0,0));
    6. pa->setEndValue(QRect(100,100,500,350));
    7. pa->setTargetObject(this);
    8. pa->setPropertyName("geometry");
    9. QPropertyAnimation * pb0=new QPropertyAnimation(ui->centralWidget, "visible"); //this animation shows the centralWidget
    10. pb0->setStartValue(false);
    11. pb0->setEndValue(true);
    12. pb0->setDuration(10);
    13. QPropertyAnimation *pb=new QPropertyAnimation(); //and this one gives me a fade in effect
    14. pb->setDuration(1000);
    15. pb->setStartValue(0.0f);
    16. pb->setEndValue(1.0f);
    17. pb->setTargetObject(ui->centralWidget);
    18. pb->setPropertyName("windowOpacity");
    19. QSequentialAnimationGroup *ag=new QSequentialAnimationGroup();
    20. ag->addAnimation(pa);
    21. ag->addAnimation(pb0);
    22. ag->addAnimation(pb);
    23. ag->setLoopCount(2);
    24. ag->start();
    25. }
    To copy to clipboard, switch view to plain text mode 

    Happens that only the first animation seems to get executed, the centralWidget is not showed and there is no fade in for the controls...
    This code doesn't give me any error code (all properties are ok). And if I remove de pb0 animation, the fade doesn't happen too.

    What is wrong??

    Thanks in advance.

  2. #2
    Join Date
    Aug 2011
    Posts
    44
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows Symbian S60

    Default Re: QSequentialAnimationGroup don't seems to start all animations

    IIRC windowOpacity works for windows only, i.e. widgets with no parent widget.
    Your centralWidget is not a window. Correct?
    If so use QGraphicsOpacityEffect instead.
    As to your "pb0" which should animate bool value.
    I'm looking at QVariantAnimation class (which is the ancestor of QPropertyAnimation class) documentation and I'm not seeing bool in the list of supported property types.
    So I'm not sure bool property can be animated.
    Maybe opacity animation is enough (despite of "speed")?

  3. #3
    Join Date
    Jul 2011
    Location
    Brasil
    Posts
    39
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSequentialAnimationGroup don't seems to start all animations

    Thanks for the tips

    I was hiding the central widget to avoid it to be resizing every widget inside... I have a layout with many controls, and this is cpu-intense, breaking the effect :S
    I'll try animating the QGraphicsOpacityEffect
    You are right, there is no way to "animate" a bool... I'll try that with the signal of animation changed... a Direct Connection should fix it

    thanks a lot

Similar Threads

  1. Animations
    By hema in forum Newbie
    Replies: 2
    Last Post: 11th July 2011, 12:05
  2. Animations
    By hema in forum The GraphicsView Framework
    Replies: 0
    Last Post: 8th July 2011, 06:54
  3. Replies: 0
    Last Post: 10th December 2010, 13:36
  4. How to remove animations?
    By mirelon in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2010, 09:41
  5. animations in Interview Delegates
    By eean in forum Qt Programming
    Replies: 5
    Last Post: 8th August 2007, 23:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.