Sliding objects animation



  • Hello,
    let's say I have several QML objects and I want to show them one at time. When a new one is requested the current one should exit and the new one should enter.
    I'm not going to rely on ready-to-use QML Types like StackView or SwipeView because I might need to customize a lot the behavior and the animation.

    The main point is understand how to handle the reposition of the items.
    Sample behavior:

    1. at first, item A is shown at (0, 0), all other items are placed at (X, 0) i.e. off-screen on the right edge
    2. when the item C is requested I start an animation to move A off-screen on the left side and let B to enter from right.
    3. now if another item is requested (A, B, etc...) the same should happen. So C exits from the left and the new one enters from the right

    The problem is I need to reposition each "exited" items off-screen on the right side in order to be ready for another request.
    I could do this using a function that cycle all items and if they aren't the current one, it will move them to the idle position.
    But I don't know how to programmatically reference a QML Object because the id is not a string.



  • @Mark81 Well, I've just discovered the objectName property. Not so straight (it requires cycling among all children) but it works.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.