qtqmlqtquick2flickable

QML flickable print height/width while dragging view


I want to be able to print the height/width of the Flickable view while dragging it. I believe it can be done using onDraggingChanged or onMovingChanged, since a similar event listener onTextChanged does the job of listening text changes in text controls. I tried this:

    Flickable{
    id: flick
    height: parent.height - 40
    width: parent.width - 40
    anchors.bottom: parent.bottom
    anchors.right: parent.right
    anchors.margins: 20
    flickableDirection: Flickable.HorizontalAndVerticalFlick
    Rectangle{
        anchors.fill: parent
        color: "steelblue"
    }
    onMovingChanged: {
        console.log("onMovingChanged")
        console.log("height:", height)
    }
    onDraggingChanged: {
        console.log("onDraggingChanged")
        console.log("height:", height)
    }
}

But those event listeners will only print the height on the start and end of dragging/moving the flickable. So how do I achieve this?


Solution

  • I believe Flickable.contentXChanged and Flickable.contentYChanged signals are what you need.

    Also Text.textChanged is emitted every time text changes.