【发布时间】:2016-05-20 15:08:28
【问题描述】:
我想创建一个像MultiPointTouchArea 一样工作的对象(因此它会有 touchUpdated 信号)但它不会窃取触摸,因此放置在它下面的对象也将接收触摸事件。
解决方案可能需要创建 C++ 对象。
有没有一种简单的方法来创建这样的对象?是否可以在不“窃取”事件的情况下处理(触摸)事件?任何提示将不胜感激。
这是我正在尝试做的一个例子。我想触顶Rectangle,但同时我想要MultiPointTouchAreas 进程触动:
import QtQuick 2.3
import QtQuick.Window 2.2
Window {
visible: true
width: 300
height: 300
Rectangle {
id: rectangle1
anchors.centerIn: parent
width: 150
height: width
color: "red"
MultiPointTouchArea {
anchors.fill: parent
mouseEnabled: false
onTouchUpdated: {
console.log("Bottom touch area contains:",
touchPoints.length,
"touches.")
}
}
}
Rectangle {
id: rectangle2
anchors.centerIn: parent
width: 100
height: width
color: "blue"
MultiPointTouchArea {
anchors.fill: parent
mouseEnabled: false
onTouchUpdated: {
console.log("Top touch area contains:",
touchPoints.length,
"touches.")
}
}
}
}
【问题讨论】:
-
您是否尝试过将
MultiPointTouchArea.mouseEnabled设置为false? -
@mkrus 我试过了。它不工作。
标签: event-handling qml qt5 touch-event