Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Synchronize SequentialAnimation between items in ListView or Repeater



  • I'm looking for a good way to sync blinking animations in a ListView or Repeater, so that for example, a ListView of 50 visible lines/items which have a blinking error state icon, would blink (1sec/1sec) synchronously, and so reduce the need to redraw UI on a slow embedded device screen.
    On a worst case scenario, UI is redrawn on every 1sec/50*2=10ms overloading the CPU (there is no GPU), when is could do it just every 1sec (all on/off at once).

    My blink animation is:

    SequentialAnimation {
        id: blinking
        running: true
        loops: Animation.Infinite
        PropertyAnimation {
            target: errorText
            property: "color"
            to: "#000000"
            duration: 0
        }
        PauseAnimation {
            duration: 1000
        }
        PropertyAnimation {
            target: errorText
            property: "color"
            to: "#FFFFFF"
            duration: 0
        }
        PauseAnimation {
            duration: 1000
        }
    }
    
    

    Is there any way to reduce UI redraw frequency of QML application. Lets say we only want to redraw UI on every 500ms, even when on our model data may be constantly changing. Or should we just not use view binding (Q_PROPERTY(bool foo READ getFoo NOTIFY fooChanged) at all, but make a timer and a update loop to manually read values from C++ model and update view variables?


  • Qt Champions 2018

    Is the issue only for the blinking animations or also related to the repainting due to other too frequent model changes?



  • @GrecKo said in Synchronize SequentialAnimation between items in ListView or Repeater:

    too frequent model changes

    Sort of, it is the model where the change originates, when QList List Items get updated in a loop/sequence, and not all at once. This causes the UI to update following model change. Maybe the model needs some sort of collect-all-and-commit-at-once system...
    Using a 1000ms Timer in a parent, and passing down the blink as bool, seems to help a little. onBlinkModeChanged {} then does the blink if enabled..

    MainItem {
      id: mainItem
      property bool blinkMode: false
      ChildItem {
        blinkMode: mainItem.blinkMode
      }
    }
    
    ....
    onTriggered: mainItem.blinkMode = !mainItem.blinkMode
    

Log in to reply