Qt 5.12 quick ,i scaling a image by two fingers touch event, image's Y position not correct when second point where it on the frist point right and Top was pressed .
can't zoom normaly when point1.x and pint2.x very closely
my project file tree
Source
main.cpp
Resource
qml.qrc
/
2.png
main.qml
Root.qml
RootForm.ui.qml
main.qml
and main.cpp
just display Root form, nothing special
RootForm.ui.qml
import QtQuick 2.4
Item {
property int prePointX: 0
property int curPointX: 0
property int prePointY: 0
property int curPointY: 0
property int preDistanceX: 0
property int curDistanceX: 0
property int preDistanceY: 0
property int curDistanceY: 0
property int pngWidth: png1.width
property int pngHeight: png1.height
property alias touchArea: touchArea
property alias png1: png1
property alias p1: touchPoint1
property alias p2: touchPoint2
MultiPointTouchArea {
id: touchArea
touchPoints: [
TouchPoint {
id: touchPoint1
},
TouchPoint {
id: touchPoint2
}
]
anchors.fill: parent
}
Image {
id: png1
source: "2.png"
fillMode: Image.PreserveAspectFit
width: 200
height: 220
x: parent.width / 2 - png1.width / 2
y: parent.height / 2 - png1.height / 2
}
}
Root.qml
import QtQuick 2.4
Item {
property int prePointX: 0
property int curPointX: 0
property int prePointY: 0
property int curPointY: 0
property int preDistanceX: 0
property int curDistanceX: 0
property int preDistanceY: 0
property int curDistanceY: 0
property int pngWidth: png1.width
property int pngHeight: png1.height
property alias touchArea: touchArea
property alias png1: png1
property alias p1: touchPoint1
property alias p2: touchPoint2
MultiPointTouchArea {
id: touchArea
touchPoints: [
TouchPoint {
id: touchPoint1
},
TouchPoint {
id: touchPoint2
}
]
anchors.fill: parent
}
Image {
id: png1
source: "2.png"
fillMode: Image.PreserveAspectFit
width: 200
height: 220
x: parent.width / 2 - png1.width / 2
y: parent.height / 2 - png1.height / 2
}
}
question from:
https://stackoverflow.com/questions/65860281/qt-qml-scaling-a-image-by-touch-event-image-y-not-correct-when-the-second-poin 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…