Check the touch device type to prevent touch pads from being handled as touch
screens.
No check required on TouchUpdate and TouchEnd, because if TouchBegin is not
accepted (return true) no following TouchUpdate/End Events are received.
- if (event->type() == QEvent::TouchBegin) {
+#if QT_VERSION >= 0x050000
+ if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->device()->type()==QTouchDevice::TouchScreen) {
+#else
+ if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->deviceType()==QTouchEvent::TouchScreen) {
+#endif
// Enable scrolling by draging, disable selecting/clicking content
setDragMode(QGraphicsView::ScrollHandDrag);
setInteractive(false);
// Enable scrolling by draging, disable selecting/clicking content
setDragMode(QGraphicsView::ScrollHandDrag);
setInteractive(false);
}
// Applying the movement happens automatically by the drag-mode
}
}
// Applying the movement happens automatically by the drag-mode
}
-
- if (event->type() == QEvent::Wheel || event->type() == QEvent::TouchBegin || event->type() == QEvent::TouchUpdate) {
+#if QT_VERSION >= 0x050000
+ if (event->type() == QEvent::Wheel || (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->device()->type()==QTouchDevice::TouchScreen) || event->type() == QEvent::TouchUpdate) {
+#else
+ if (event->type() == QEvent::Wheel || (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->deviceType()==QTouchEvent::TouchScreen) || event->type() == QEvent::TouchUpdate) {
+#endif
if (!verticalScrollBar()->isVisible()) {
scene()->requestBacklog();
return true;
if (!verticalScrollBar()->isVisible()) {
scene()->requestBacklog();
return true;
bool TreeViewTouch::event(QEvent *event) {
bool TreeViewTouch::event(QEvent *event) {
- if (event->type() == QEvent::TouchBegin) {
+#if QT_VERSION >= 0x050000
+ if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->device()->type()==QTouchDevice::TouchScreen) {
+#else
+ if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->deviceType()==QTouchEvent::TouchScreen) {
+#endif
// Register that we may be scrolling, set the scroll mode to scroll-per-pixel
// and accept the event (return true) so that we will receive TouchUpdate and TouchEnd/TouchCancel
_touchScrollInProgress = true;
// Register that we may be scrolling, set the scroll mode to scroll-per-pixel
// and accept the event (return true) so that we will receive TouchUpdate and TouchEnd/TouchCancel
_touchScrollInProgress = true;