Important: Please read the Qt Code of Conduct -
PinchArea do not work well in Qt 5.4
Hi all,
I am using Flickable +PinchArea to provide pinching gesture for a photo . However, I found that the PinchArea do not work well in Qt 5.4. Here is an example code :
@
import QtQuick 2.4
import QtQuick.Window 2.2
Window {
id : window
visible: true
Flickable { id : flickable anchors.fill: parent interactive: true contentWidth: container.width contentHeight: container.height flickableDirection: Flickable.HorizontalAndVerticalFlick PinchArea { pinch.target : container pinch.maximumScale: 8 pinch.minimumScale: 0.5 anchors.fill: parent onPinchStarted: { console.log("pinch started"); flickable.interactive = false } onPinchFinished: { flickable.interactive = true; } } Item { id: container width: window.width height: window.height Rectangle { anchors.centerIn: parent width: window.width * 0.5 height: window.height * 0.5 color : "red" } } }
}
@
It shows a red rectangle in the center and you may use two fingers to zoom in / out. In Qt 5.3.2 , the PinchArea is working fine.
But in Qt 5.4, the pinch area's PinchStarted signal is triggered only if both of the fingers touch on the screen at the SAME time. It don't fulfill the common practise for pinching gesture.
The code has been tested in Android and iOS.
That is a bug or I should use another component for handling pinching gesture?
Thanks for any advise.
Hi !
Consider examples provide from Qtcreator :
"PhotoSurface": in this case
It's a good way to resolve quickly your issue.
Regards.
Hi Johan,
Thank for your reply. However, the PhotoSurface code do not work with my case. Since I need to integrate Flickable and PinchArea together , but the PhotoSurface just show how PinchArea work.
Since my example code is copied from another project , it is not pretty/simple enough to show the problem. I have reposted another version.
As Qt 5.4.1 is launched already , I have tested but still has same problem.
The reason I need Flickable is because I would like to let user to drag the photo and it will continues to move slightly after released the finger and return to bound afterward.
May be it is not the problem of PInchArea, but there has something wrong with Flickable that steal the mouse event from PinchArea
I have reported it as a bug already and it is marked as P2.
[QTBUG-44645] Flickable and PinchArea are not working well together - Qt Bug Tracker