0

When I use the scale to control the zoom in Flickable (in zoom out), the Flickable shrinks inside the item. I want to always Flickable fill parent with scale change. How can do it?

Results of my code

Flickable {
    id: flickable

    anchors.fill: parent
    anchors.centerIn: parent

    contentWidth: 4000
    contentHeight: 4000
    focus: true


    ScrollBar.vertical: ScrollBar {
        width: 5
        policy: ScrollBar.AsNeeded
    }

    ScrollBar.horizontal: ScrollBar {
        height: 5
        policy: ScrollBar.AsNeeded
    }

    Keys.onPressed: event => {
                        if (event.key === Qt.Key_Control) {
                            privateProperty.ctrlPressedAndHold = true
                        }
                    }
    Keys.onReleased: privateProperty.ctrlPressedAndHold = false

    MouseArea {
        anchors.fill: parent
        z: -10
        onWheel: wheel => {
                     if(!flickable.privateProperty.ctrlPressedAndHold)
                     return;
                     if(wheel.angleDelta.y > 0)
                     flickable.scale += 0.1;
                     else if (flickable.scale > 0.5) {
                         flickable.scale -= 0.1;
                     }
                 }

        onClicked: {
            scene.selectionModel.select(null)
            flickable.forceActiveFocus()
        }
    }
}

I need to Flicable fill the parent at any scale.

0 Answers0