1
votes

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?

1
You know that the height will never change in your example, right? Besides, printing something in the onContentXChanged/onContentYChanged as Filip suggests will likely slow your GUI down.Yoann Quenach de Quivillic
@Yoann I wanted to play around with animations and resizing of layouts so I needed to know the height at each location. I'm very much aware about the drawback of using it :)Akash Agarwal

1 Answers

1
votes

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

  • Flickable.draggingChanged is emitted only when drag is starting and ending.
  • Flickable.movingChanged is emitted only when Flickable starts and ends moving.
  • Flickable.contentXChanged is emitted every time content is being moved horizontally.
  • Flickable.contentYChanged is emitted every time content is being moved vertically.

Also Text.textChanged is emitted every time text changes.