Results 1 to 3 of 3

Thread: Animation not working on transition between states

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Innsbruck, Austria
    Posts
    62
    Thanks
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Animation not working on transition between states

    I'm taking a look at the new animation framework as well as QStateMachine and I'm trying to make a QGraphicsView zoom in when I select an item and zoom out when no item is selected. I want to animate the zoom effect.

    The animation is working fine when zooming in but it's not working when zooming out. It just zooms out suddenly. It's strange because the setZoom() slot I've added to my QGraphicsView subclass gets called but the zoom factor just jumps from 2 to 1 without intermediate values.

    Qt Code:
    1. QStateMachine machine;
    2. QState *globalOverview = new QState(&machine);
    3. globalOverview->assignProperty(&view, "zoom", qreal(1.0));
    4. machine.setInitialState(globalOverview);
    5.  
    6. QPropertyAnimation *animation = new QPropertyAnimation(&view, "zoom");
    7. animation->setDuration(250);
    8. animation->setEasingCurve(QEasingCurve::InOutQuad);
    9. machine.addDefaultAnimation(animation);
    10.  
    11. for(int i = 0; i < 100; i++) {
    12. ExtensionItem *item = new ExtensionItem(i);
    13. layout.addItem(item);
    14. scene.addItem(item);
    15.  
    16. QState *state = new QState(&machine);
    17. state->assignProperty(&view, "zoom", qreal(2.0));
    18.  
    19. globalOverview->addTransition(item, SIGNAL(selected()), state);
    20. state->addTransition(item, SIGNAL(selected()), globalOverview);
    21. state->addTransition(&scene, SIGNAL(selectionCleared()), globalOverview);
    22. }
    23.  
    24. machine.start();
    To copy to clipboard, switch view to plain text mode 

    Any idea why it isn't working?
    Attached Files Attached Files

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.