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. Slide In and Slide Out Animation QML
Forum Updated to NodeBB v4.3 + New Features

Slide In and Slide Out Animation QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 5.1k Views 2 Watching
  • 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.
  • AutomataA Offline
    AutomataA Offline
    Automata
    wrote on last edited by Automata
    #1

    Hello all, please I have a challenge creating a slide out, slide in effect.

    I have created a qml component in a separate qml file from my main qml file, with details of its interface, the state that triggers the transition and the transition.

    In my main qml file I dynamically created the custom qml component to cover the screen, displaying information, and when new information becomes available, I create a new custom component dynamically, position it by the screen width to the left of the screen , and set the state of both components (the new and the existing component) that triggers their transition, to create an effect of the new component pushing out the old one and with the new now covering the screen. When new information becomes available again, I destroy the last component pushed out, and repeat the process.

    The program just does not work, any help would be really appreciated. Thanks

    Below is an idealization of what the custom component looks like

    Rectangle {
        id: main
        width: parent.width
        height: parent.height
        color: "blue"
    
        property bool startSliding: false
    
        states: State {
            name: "slideOut"; when: main.startSliding
            PropertyChanges { target: main; x: (x + main.width); y: 0 }
        }
    
        transitions: Transition {
            to: "slideOut"
            NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 400 }
       }
    
    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @Automata Silly question probably, did you set main.startSliding to true ?

      157

      1 Reply Last reply
      0
      • AutomataA Offline
        AutomataA Offline
        Automata
        wrote on last edited by
        #3

        Solved now!
        Happened I had to create 2 states and 2 transitions, yipee!

        states: [
                State {
                    name: "moveOut"; when: main.moveOut
                    PropertyChanges { target: main; x: width; y: 0 }
                },
                State {
                    name: "moveIn"; when: main.moveIn
                    PropertyChanges { target: main; x: 0; y: 0 }
                }
            ]
        
            transitions: [
                Transition {
                    to: "moveOut"
                    NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 400; loops: 1 }
                },
                Transition {
                    to: "moveIn"
                    NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 400; loops: 1 }
                }
            ]
        
        Aleksey_KA 1 Reply Last reply
        0
        • AutomataA Automata

          Solved now!
          Happened I had to create 2 states and 2 transitions, yipee!

          states: [
                  State {
                      name: "moveOut"; when: main.moveOut
                      PropertyChanges { target: main; x: width; y: 0 }
                  },
                  State {
                      name: "moveIn"; when: main.moveIn
                      PropertyChanges { target: main; x: 0; y: 0 }
                  }
              ]
          
              transitions: [
                  Transition {
                      to: "moveOut"
                      NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 400; loops: 1 }
                  },
                  Transition {
                      to: "moveIn"
                      NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 400; loops: 1 }
                  }
              ]
          
          Aleksey_KA Offline
          Aleksey_KA Offline
          Aleksey_K
          wrote on last edited by Aleksey_K
          #4

          @Automata do You have full example please? Thanks!

          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