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. StateMachine or SequentialAnimation?

StateMachine or SequentialAnimation?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 129 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.
  • M Offline
    M Offline
    Mark81
    wrote on last edited by
    #1

    I'm looking for an advice about the best approach for this scenario.

    I have to write a QML item that do the following:

    • it has 4 states, let's call them rise1, wait1, rise2, wait2
    • they runs in circle: rise1 -> wait1 -> rise2 -> wait2 -> rise1 -> ...
    • each state has a specific duration in time (I have 4 properties to store their duration)
    • a text shows the current time spent in each state
    • there are two kind of transitions:
      • a transition between one state and another (i.e., change the color and the label of the text)
      • an animation that runs during the whole duration of the state (i.e. the text moves with the same duration of the current state)

    I can use a SequentialAnimation, where each step is a state. But I will have difficult to provide internal animations (the counter to be updated each second). I have to place ScriptAction here and there to initialize the timer, update the label, etc...:

    SequentialAnimation {
        // state: rise1
        ScriptAction { script: initializeRise1(); }
        ParallelAnimation {
            PropertyAnimation { /* animation during rise1*/ } 
            PropertyAnimation { /* animation during rise1*/ } 
        }
        ParallelAnimation {
            PropertyAnimation { /* transition to wait1 */ } 
            PropertyAnimation { /* transition to wait1 */ } 
       }
       ScriptAction { script: finalizeRise1(); }
    
       // state: wait1
       // ...
    }
    
    Timer {
        id: timer
        // this will update the counter
    }
    
    function initializeRise1() {
        myLabel.text = "Rise 1"
        timer.interval = 10
        timer.running = true
    }
    

    Do you think a StateMachine can be more suitable for this use case?

    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