我一直在尝试在Mac鼠标垫上使用拇指+双指手势来调出我的应用程序的主菜单。我很难记录拇指和手指所采用的相反方向,并在发生合适事件时创建信号处理程序。我尝试将窗口分成两个,以允许两个多点触控区域,一个(底部)用于拇指,另一个(上半部分)用于手指,但这完全不起作用。这是我到目前为止的测试代码:
import QtQuick 2.0
Rectangle {
id: mainView
// width: 600
// height: 900
Rectangle {
x: 24
y: 14
z:2
width: 666
height: 560
color: "#ffa800"
Text {
z:2
font.pointSize: 12
id: logTxt1
text:
"distance traversed :"+ (touch1.y - touch1.startY)
x: 8
y: 8
height: 68
width: 144
function log(txt){
text = txt+"\n"
}
}
Text {
font.pointSize: 12
z:2
id: logTxt2
text:
"distance traversed :"+ (touch2.y - touch2.startY)
x: 8
y: 98
height: 58
width: 165
function log(txt){
text = txt+"\n"
}
}
Text {
z:2
font.pointSize: 12
id: logTxt3
text:
"distance traversed :"+ (touch3.y - touch3.startY)
x: 11
y: 180
height: 68
width: 141
function log(txt){
text = txt+"\n"
}
}
Text {
font.pointSize: 12
z:2
id: logTxt4
text:
"distance traversed :"+ (touch4.y - touch4.startY)
x: 20
y: 266
height: 68
width: 137
function log(txt){
text = txt+"\n"
}
}
Text {
z:2
font.pointSize: 12
id: logTxt5
text:
"distance traversed :"+ (touch5.y-touch5.startY)
x: 24
y: 362
height: 58
width: 134
function log(txt){
text = txt+"\n"
}
}
Text {
id: message
x: 20
y: 454
width: 380
height: 49
text: qsTr("Text")
font.pixelSize: 12
}
}
VisualItemModel {
id: itemModel
Rectangle { z:3; anchors.fill: parent; color: "red" }
Rectangle { z:1; anchors.fill: parent;
Rectangle {
height: 200
width : 600
color: "yellow"
}
color: "#028000" }
Rectangle { z: 1; anchors.fill: parent; color: "#0500ff" }
}
MultiPointTouchArea {
id: multiGest
width: parent.width
height: parent.height *0.5
anchors.topMargin: mainView.top
minimumTouchPoints: 2
maximumTouchPoints: 4
touchPoints: [
TouchPoint { id: touch1 },
TouchPoint { id: touch2 },
TouchPoint { id: touch3 },
TouchPoint { id: touch4 }
]
}
MultiPointTouchArea {
id: multiGest2
width: parent.width
height: parent.height *0.5
anchors.bottomMargin: mainView.bottom
minimumTouchPoints: 1
maximumTouchPoints: 1
touchPoints: [
TouchPoint { id: touch5 }
]
}
}