QML SwipeView 两指滑动
QML SwipeView two-finger swipe
我正在使用 SwipeView,我想防止它在触摸屏上用单指滑动从一个页面滑动到另一个页面。如何限制 SwipeView 只能用两指滑动?
import QtQuick 2.9
import QtQuick.Controls 2.2
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Tabs")
SwipeView {
id: swipeView
anchors.fill: parent
currentIndex: tabBar.currentIndex
Page1Form {
}
Page2Form {
}
}
footer: TabBar {
id: tabBar
currentIndex: swipeView.currentIndex
TabButton {
text: qsTr("Page 1")
}
TabButton {
text: qsTr("Page 2")
}
}
}
Page1Form {
MultiPointTouchArea {
anchors.fill: parent
mouseEnabled: false
minimumTouchPoints: 1
maximumTouchPoints: 10
onTouchUpdated:{
var pointId=[];
for (var touch in touchPoints){
pointId.push(touchPoints[touch].pointId);
//console.log(pointId);
if(pointId.length === 2){
swipeView.interactive = true;
}else{
swipeView.interactive = false;
}
}
}
}
}
我正在使用 SwipeView,我想防止它在触摸屏上用单指滑动从一个页面滑动到另一个页面。如何限制 SwipeView 只能用两指滑动?
import QtQuick 2.9
import QtQuick.Controls 2.2
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Tabs")
SwipeView {
id: swipeView
anchors.fill: parent
currentIndex: tabBar.currentIndex
Page1Form {
}
Page2Form {
}
}
footer: TabBar {
id: tabBar
currentIndex: swipeView.currentIndex
TabButton {
text: qsTr("Page 1")
}
TabButton {
text: qsTr("Page 2")
}
}
}
Page1Form {
MultiPointTouchArea {
anchors.fill: parent
mouseEnabled: false
minimumTouchPoints: 1
maximumTouchPoints: 10
onTouchUpdated:{
var pointId=[];
for (var touch in touchPoints){
pointId.push(touchPoints[touch].pointId);
//console.log(pointId);
if(pointId.length === 2){
swipeView.interactive = true;
}else{
swipeView.interactive = false;
}
}
}
}
}