Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-25046

Example Usage for QML AnimatedImage Element is wrong -- Needed some modification

XMLWordPrintable

      The example usage of QML AnimatedImage Element here: http://developer.qt.nokia.com/doc/qt-4.8/qml-animatedimage.html needs changes to work properly.

      In the example given the property frames will be computed to undefined as the frames is not present inside the AnimatedImage element.
      We can also directly compute the frames like this:

      computing X
      x: (animationImg.width - width) * animationImg.currentFrame / animationImg.frameCount
      

      but it will result in non-NOTIFYable properties error as frameChange is not being notified by any event/signal

      QDeclarativeExpression: Expression "(function $x() { return (animationImg.width - width) * animationImg.currentFrame / animationImg.frameCount })" depends on non-NOTIFYable properties:
      QDeclarativeAnimatedImage::frameCount
      So to get rid of this we move the status value of the status bar into AnimatedImage element like below:

      Manipulated Code
      import QtQuick 1.1
      
       Rectangle {
           width: animation.width; height: animation.height + 10
           property int xx;
      
           AnimatedImage {
               id: animation;
               source: "Images/ExampleAnimation.gif"
               onCurrentFrameChanged: {
                     xx = (animation.width-status.width) * (animation.currentFrame/animation.frameCount)
               }
           }
      
           Rectangle {
               id: status
               //property int frames: animation.frameCount
               width: 4; height: 10
               x:  parent.xx
               y: animation.height
      
               color: "red"
           }
       }
      

      This works fine.
      <mouli_> helped me to solve this issue in #qt-qml . ThankYou <mouli_>.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Unassigned Unassigned
            inblueswithu inblueswithu
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 1 day
                1d
                Remaining:
                Remaining Estimate - 1 day
                1d
                Logged:
                Time Spent - Not Specified
                Not Specified

                  There are no open Gerrit changes