Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. BorderImage: switch between half and full opacity
QtWS25 Last Chance

BorderImage: switch between half and full opacity

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 2.5k Views
  • 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 Offline
    B Offline
    bkamps
    wrote on last edited by
    #1

    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
    0
    • T Offline
      T Offline
      task_struct
      wrote on last edited by
      #2

      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
      0
      • B Offline
        B Offline
        bkamps
        wrote on last edited by
        #3

        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
        0
        • T Offline
          T Offline
          task_struct
          wrote on last edited by
          #4

          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
          0
          • B Offline
            B Offline
            bkamps
            wrote on last edited by
            #5

            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
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved