Results 1 to 10 of 10

Thread: SequentialAnimation created from JS not animating

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2014
    Posts
    6
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default SequentialAnimation created from JS not animating

    Hi all,

    I am trying to create and set animations dynamically. The animations works perfectly if statically written in original QML file. When creating animations from JS, it sucks. Nothing is animating.


    The original qml code:
    QML:
    Qt Code:
    1. Image {
    2. id: prologueImage
    3. anchors.fill: parent
    4. source: "image://encimg/prologue/splash.png"
    5. }
    6.  
    7. SequentialAnimation {
    8. running: true;
    9. PropertyAnimation {
    10. from: 0
    11. to: 1
    12. target: prologueImage
    13. duration: 2000
    14. property: "opacity"
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 


    New code:
    QML:
    Qt Code:
    1. import "PFunc.js" as PFunc
    2.  
    3. Rectangle {
    4. id: imgWrapper
    5. anchors.fill: parent
    6. Component.onCompleted: {
    7. var image = PresenterFunctions.createImage(imgWrapper);
    8. image.source = "image://encimg/prologue/splash.png";
    9.  
    10. var seqAnimation = PFunc.createSequentialAnimation(imgWrapper);
    11. var aniFIn = PFunc.createPropertyAnimation(seqAnimation, 0, 1, image, "opacity", 2000);
    12.  
    13. seqAnimation.start();
    14. }
    15.  
    16. }
    To copy to clipboard, switch view to plain text mode 

    JS (PFunc.js):
    Qt Code:
    1. function createImage(parent) {
    2. var image = Qt.createQmlObject("import QtQuick 2.2; Image {anchors.fill: parent; }", parent);
    3. return image;
    4. }
    5.  
    6. function createSequentialAnimation(parent) {
    7. var animation = Qt.createQmlObject("import QtQuick 2.2; SequentialAnimation {}", parent);
    8. return animation;
    9. }
    10.  
    11. function createPropertyAnimation(parent, from, to, target, prop, duration) {
    12. var animation = Qt.createQmlObject("import QtQuick 2.2; PropertyAnimation {}", parent);
    13. animation.from = from;
    14. animation.to = to;
    15. animation.target = target;
    16. animation.property = prop;
    17. animation.duration = duration;
    18. return animation;
    19. }
    To copy to clipboard, switch view to plain text mode 

    Note that dynamically created image was showing correctly.

    Platform:
    Win 8.1 Qt 5.3.1 MinGW 4.8.2 32bit

    Any ideas? Am I missing anything?

    Thanks.
    Last edited by hmasterwang; 27th July 2014 at 18:34. Reason: reformatted to look better

    Wishes.
    Afa.L Cheng

Similar Threads

  1. Animating QDockWidget
    By vajindarladdad in forum Qt Programming
    Replies: 2
    Last Post: 18th January 2021, 17:27
  2. Animating QGraphicsPixmapItem
    By 2lights in forum Qt Programming
    Replies: 3
    Last Post: 27th August 2013, 12:59
  3. Replies: 4
    Last Post: 8th April 2013, 04:19
  4. animating a QGraphicsObject
    By tommy22 in forum Qt Programming
    Replies: 4
    Last Post: 7th January 2013, 11:20
  5. Animating QSplashScreen
    By pssss in forum Qt Programming
    Replies: 3
    Last Post: 3rd September 2011, 11:39

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
  •  
Qt is a trademark of The Qt Company.