2023-06-17

Delete images from automatically scrolling Row in Flickable

Background.qml

import QtQuick
Flickable{
    id:flickable
    anchors.fill:parent
    contentWidth:row.implicitWidth
    interactive:false
    Row{
        id:row
        anchors.fill:parent
    }
    Timer{
        interval:10;
        running:true;
        repeat:true
        onTriggered:{
            if(flickable.atXEnd){
                Qt.createComponent('Pic.qml').createObject(row)
            }
            flickable.contentX++
        }
    }
}

Pic.qml

import QtQuick
Image{
    sourceSize.height:parent.height
    fillMode:Image.PreserveAspectFit
    asynchronous:true
    source:'file://'+RandomImage
}

This continuously scrolls a strip of randomly chosen images from left to right.

This works nicely, but the only problem that remains is that images that scroll offscreen need to be deleted.

What's the best way to achieve this?



No comments:

Post a Comment