Hello,

My problem today is about tactil event on QScrollArea.
My view has:

One ScrollArea which contain some ToolButton

I create my class ScrollArea like this:

Qt Code:
  1. ScrollArea::ScrollArea(QWidget *parent)
  2. :QScrollArea(parent)
  3. {
  4. setAttribute(Qt::WA_AcceptTouchEvents);
  5. }
  6.  
  7. bool ScrollArea::event(QEvent* event)
  8. {
  9. switch (event->type()) {
  10. case QEvent::TouchBegin:
  11. {
  12. QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
  13. QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
  14. touchPoints.first().setLastPos(touchPoints.first().pos());
  15. }
  16.  
  17. break;
  18. case QEvent::TouchUpdate:
  19. case QEvent::TouchEnd:
  20. {
  21. QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
  22.  
  23. QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
  24. const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first();
  25. if(touchPoints.count() == 1 && !touchPoint0.lastPos().isNull() )
  26. {
  27. // determine scale factor
  28. QPointF delta = touchPoint0.pos() - touchPoint0.lastPos() ;
  29. if(touchPoint0.lastPos().x() > touchPoint0.pos().x())//old position is qpoint it remembers last position
  30. this->horizontalScrollBar()->setValue(this->horizontalScrollBar()->value() - delta.x());
  31.  
  32. if(touchPoint0.lastPos().x() < touchPoint0.pos().x())
  33. this->horizontalScrollBar()->setValue(this->horizontalScrollBar()->value() - delta.x());
  34.  
  35. if(touchPoint0.lastPos().y() > touchPoint0.pos().y())
  36. this->verticalScrollBar()->setValue(this->verticalScrollBar()->value() - delta.y());
  37.  
  38. if(touchPoint0.lastPos().y() < touchPoint0.pos().y())
  39. this->verticalScrollBar()->setValue(this->verticalScrollBar()->value() - delta.y());
  40.  
  41. return true;
  42. }
  43.  
  44. }break;
  45.  
  46. default:
  47. return QWidget::event(event);
  48. break;
  49. }
  50. }
To copy to clipboard, switch view to plain text mode 

Of course, I have create my class ToolButton to accept touchEvents:

Qt Code:
  1. this->setAttribute(Qt::WA_AcceptTouchEvent);
To copy to clipboard, switch view to plain text mode 

The scroll works fine if the start of my touch is on the background of ScrollArea. If my first touch begin on ToolButton, the event is not sent to my parent (here ScrollArea).

Someone can help me?

Thanks.