# QVTKInteractorAdapter asumes QTouchEvent point IDs start at zero when Qt specifies to not asume that

**URL:** https://discourse.vtk.org/t/qvtkinteractoradapter-asumes-qtouchevent-point-ids-start-at-zero-when-qt-specifies-to-not-asume-that/8342
**Category:** Development
**Created:** [April 20, 2022, 4:30pm UTC](https://discourse.vtk.org/t/qvtkinteractoradapter-asumes-qtouchevent-point-ids-start-at-zero-when-qt-specifies-to-not-asume-that/8342 "2022-04-20T16:30:08Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Iker\_Salmon](https://discourse.vtk.org/user_avatar/discourse.vtk.org/iker_salmon/32/5051_2.png) [@Iker\_Salmon](https://discourse.vtk.org/u/Iker_Salmon)
#### Post date: [April 20, 2022, 4:30pm UTC](https://discourse.vtk.org/t/qvtkinteractoradapter-asumes-qtouchevent-point-ids-start-at-zero-when-qt-specifies-to-not-asume-that/8342/1 "2022-04-20T16:30:09Z")

</div>

And because of this there is a bug where touch events are not working in linux machines with vtk.9 and qt 6.2

Qt seems to generate QTouch events with point IDs like 37 (for example) so when the event reaches the ProcessEvent function: it never does anything because of this code: (VTKI\_MAX\_POINTERS is defined as 5)

```auto
  if (t == QEvent::TouchBegin || t == QEvent::TouchUpdate || t == QEvent::TouchEnd)
  {
    QTouchEvent* e2 = dynamic_cast<QTouchEvent*>(e);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
    Q_FOREACH (const QTouchEvent::TouchPoint& point, e2->touchPoints())
#else
    Q_FOREACH (const QTouchEvent::TouchPoint& point, e2->points())
#endif
    {
      if (point.id() >= VTKI_MAX_POINTERS)
      {
        break;
      }
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
      QPointF pos = point.pos();
#else
      QPointF pos = point.position();
#endif

```

[Here](https://doc.qt.io/qt-6/qeventpoint.html#id-prop) is the Qt documentation stating to not to do that.

Am I missing something here?

Thanks.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [April 21, 2022, 1:45am UTC](https://discourse.vtk.org/t/qvtkinteractoradapter-asumes-qtouchevent-point-ids-start-at-zero-when-qt-specifies-to-not-asume-that/8342/2 "2022-04-21T01:45:08Z")

</div>

We use Qt/VTK touch and pen support on Windows and macOS and there are no issues. Probably multi-touch support in VTK just has not been tested on Linux. Or maybe it is a Qt6 issue.

I would not expect that there is a VTK developer who has access to a multi-touch capable Linux desktop and can dedicate time to work on this. So, the best would be if you could come up with fix that works for you and send a merge request.

---

<div class="post-metadata">

### Author: ![Iker\_Salmon](https://discourse.vtk.org/user_avatar/discourse.vtk.org/iker_salmon/32/5051_2.png) [@Iker\_Salmon](https://discourse.vtk.org/u/Iker_Salmon)
#### Post date: [April 21, 2022, 6:35am UTC](https://discourse.vtk.org/t/qvtkinteractoradapter-asumes-qtouchevent-point-ids-start-at-zero-when-qt-specifies-to-not-asume-that/8342/3 "2022-04-21T06:35:42Z")

</div>

Thanks for the answer. Actually is not only multi-touch. A single touch is even a problem (as the first point starts with an id much bigger than five.

I’ll be happy to provide a patch if I manage to find and elegant way to fix this, but my main question is still on air. I am not missing anything right?. Vtk code asumes qeventpoints ids start at zero?

Thanks again for the answer

---

<div class="post-metadata">

### Author: ![Iker\_Salmon](https://discourse.vtk.org/user_avatar/discourse.vtk.org/iker_salmon/32/5051_2.png) [@Iker\_Salmon](https://discourse.vtk.org/u/Iker_Salmon)
#### Post date: [April 21, 2022, 10:43am UTC](https://discourse.vtk.org/t/qvtkinteractoradapter-asumes-qtouchevent-point-ids-start-at-zero-when-qt-specifies-to-not-asume-that/8342/4 "2022-04-21T10:43:47Z")

</div>

Ok, I’ve created two MR but I am having problems with the reformat command in the Release One.

Anyway I found a solution and left it aviable for anyone who needs it.

Thanks!

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [April 25, 2022, 2:39pm UTC](https://discourse.vtk.org/t/qvtkinteractoradapter-asumes-qtouchevent-point-ids-start-at-zero-when-qt-specifies-to-not-asume-that/8342/5 "2022-04-25T14:39:29Z")

</div>

For reference @Iker_Salmon created these two merge requests:

[https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/9110](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/9110)

[https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/9124](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/9124)
