Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    BorderImage: switch between half and full opacity

    QML and Qt Quick
    2
    5
    2288
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      bkamps last edited by

      I want to toggle a BorderImage between half and full opacity. For now I have used a SequentialAnimation:

      @
      BorderImage {
      id: softkeyImage
      source: "images/image.png"

       SequentialAnimation {
        running: softkey.state == "fadeoutin"
        NumberAnimation { target: softkeyImage; property: "opacity"; to: 0.5; duration: 1000 }
        NumberAnimation { target: softkeyImage; property: "opacity"; to: 1; duration: 1000 }
        loops: Animation.Infinite
       }                     
      

      }
      @

      Because our embedded device is too slow I want to remove the animation and just switch between half and full opacity. How to do this easily?

      1 Reply Last reply Reply Quote 0
      • T
        task_struct last edited by

        Hello,

        you can achieve this by using "states":http://doc.qt.nokia.com/latest/qdeclarativestates.html

        "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

        • Linu...
        1 Reply Last reply Reply Quote 0
        • B
          bkamps last edited by

          Yes, as you can see i'm using state already in the SequentialAnimation. I want to replace this animation and maybe start a timer that switches between half and full opacity without animations.

          1 Reply Last reply Reply Quote 0
          • T
            task_struct last edited by

            You only start an animation using property binding. But in you case I think this is better. Try this:

            @
            SequentialAnimation {
            running: softkey.state == "fadeoutin"
            PropertyAction { target: softkeyImage; property: "opacity"; value: 0.5 }
            PauseAnimation { duration: 1000 }
            PropertyAction { target: softkeyImage; property: "opacity"; value: 1 }
            PauseAnimation { duration: 1000 }
            loops: Animation.Infinite
            }
            @

            "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

            • Linu...
            1 Reply Last reply Reply Quote 0
            • B
              bkamps last edited by

              Thanks task_struct, this seems to work. I'm going to try it on the target to check the load. I also added an "off" state to set the image to full opacity when the animation is done:

              @
              states: [
              State {
              name: "off"
              PropertyChanges { target: image; opacity: 1}
              }
              ]

              @

              1 Reply Last reply Reply Quote 0
              • First post
                Last post