There is a qml window, it is necessary to position the picture in the center and add the ability to move this picture with the mouse (ideally, I would like to move only the picture that does not fit in the window, but forbid a small one to move). To add the ability to move using the Flickable block. The following problem arises: a picture that is larger than the window is positioned correctly in the center of the window, and the small picture is shifted to the origin. Tell me what I'm doing wrong.
PS: never found an example of how to add a condition on the ability to move.
import QtQuick 2.5 import QtQuick.Window 2.2 Window { id: win visible: true width: 1000; height: 1000 Flickable { clip : true width: 1000; height: 1000 anchors.fill: parent contentHeight: myIcon.height contentWidth: myIcon.width //contentX: myIcon.width < width ? width / 2 - myIcon.width / 2 :myIcon.width / 2 - width / 2 //contentY: myIcon.height < height ? height / 2 - myIcon.height / 2 :myIcon.height / 2 - height / 2 contentX: myIcon.width / 2 - width / 2 contentY: myIcon.height / 2 - height / 2 Image { id: myIcon anchors.centerIn: parent source: "1.jpg" } } }