首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >QML SwipeView双指轻扫

QML SwipeView双指轻扫
EN

Stack Overflow用户
提问于 2021-05-25 14:03:27
回答 1查看 63关注 0票数 0

我正在使用SwipeView,我想阻止它在触摸屏上用一根手指在页面之间滑动。如何限制SwipeView只能用两个手指滑动?

代码语言:javascript
复制
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")
        }
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-30 16:12:18

代码语言:javascript
复制
 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;
                        }
                   }
               }
         }
  }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67682527

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档