qtqmlscrollviewqtquickcontrolsflickable

How do I access that the movement of a QML ScrollView has ended?


I would like to do something the moment the scrolling of a QML ScrollView has ended. From the documentation I assume that flickableItem.onMovementEnded is what I'm looking for but I never get that signal. Am I understanding "Movement" wrong? I have written this minimal QML application and my console.log gets never called. I run this on a Mac with Qt 5.7 or 5.5.1.

import QtQuick 2.5
import QtQuick.Controls 1.4

ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    ScrollView {
        id: scrollView

        anchors.fill: parent

        flickableItem.onMovementEnded: {
            console.log("onMovementEnded")
        }

        Rectangle {
            id: rect

            width: 3000
            height: 3000
        }
    }

}

I also tried to connect it via "Connections" with no luck.

Connections {
    target: scrollView.flickableItem
    onMovementEnded: {
        console.log("onMovementEnded")
    }
}

Solution

  • Based on @ddriver's input, I build a solution using onContentYChanged and a Timer. This is sufficient for me even though it is not perfect.

    import QtQuick 2.5
    import QtQuick.Controls 1.4
    
    ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        ScrollView {
            id: scrollView
    
            anchors.fill: parent
    
            flickableItem.onContentXChanged: {
                updateContentDelay.restart()
            }
    
            flickableItem.onContentYChanged: {
                updateContentDelay.restart()
            }
    
            Rectangle {
                id: rect
    
                width: 3000
                height: 3000
            }
        }
    
        Timer {
            id: updateContentDelay
            interval: 200
            repeat: false
    
            onTriggered: {
                console.log("do something")
            }
        }
    
    }