title: Pressing touchscreen triggers mousePressEvent, how do I determine if its a mouse click or a touchscreen click?
body: <p>I am using Qt 4 on Linux.</p>
  
  <p>I am implementing an application for a touchscreen display and I also have a mouse and keyboard plugged in.</p>
  
  <p>I can implement either mouse or touchscreen, but not both because they interact badly with each other. The main issue is that when I click the mouse OR press the touchscreen I get the following event triggered.</p>
  
  <p>(note: I re-implemented this function so that I can do this things I need)</p>
  
  <pre><code>MainWindow::mousePressEvent(QMouseEvent *ev)
  {
      // Handle mouse specific events
  }
  </code></pre>
  
  <p>However when I press the touchscreen I also get the same function triggered : (</p>
  
  <p>I therefore cannot distinguish between mouse clicks and touchscreen presses! – how do I get around this issue? how can I determine if it is a mouse click or a touchscreen press?</p>
  
  <p>I have tried looking at the event type, but its always = 2 (mouseClickEvent, but never TouchBegin or such). Currently I am stuck here :(</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I have looked further into this and implemented somthing like this:</p>
  
  <pre><code>MainWindow::MainWindow(QWidget *parent)
  {
  ...
      qApp-&gt;installEventFilter(this);
      setAttribute(Qt::WA_AcceptTouchEvents);
      setAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
  }
  bool MainWindow::eventFilter(QObject *, QEvent * pEvent)
  {
      switch(pEvent-&gt;type())
      {
      case QEvent::TouchBegin:
          qDebug("BEGIN");
          break;
      case QEvent::TouchUpdate:
          qDebug("UPDATE");
          break;
      case QEvent::TouchEnd:
          qDebug("END");
          break;
      case QEvent::MouseMove:
          qDebug("MOUSE");
          break;
     };
     return false;
  }
  </code></pre>
  
  <p>I found that I ALWAYS get a MouseMove event regardless of if its a touchscreen input or a mouse input.</p>
  
  <p>I decided that my hardware setup must be such that my touch screen acts like a mouse instead of a touch screen (if that's possible). So I have printed out my /dev/inputs/ to see:</p>
  
  <pre><code>root@dm814x-evm:/dev/input# ls -l
  drwxr-xr-x    2 root     root          180 Jan  1  2000 by-id
  drwxr-xr-x    2 root     root          180 Jan  1  2000 by-path
  crw-r-----    1 root     root      13,  64 Jan  1  2000 event0
  crw-r-----    1 root     root      13,  65 Jan  1  2000 event1
  crw-r-----    1 root     root      13,  66 Jan  1  2000 event2
  crw-r-----    1 root     root      13,  67 Jan  1  2000 event3
  crw-r-----    1 root     root      13,  68 Jan  1  2000 event4
  crw-r-----    1 root     root      13,  69 Jan  1  2000 event5
  crw-r-----    1 root     root      13,  70 Jan  1  2000 event6
  crw-r-----    1 root     root      13,  71 Jan  1  2000 event7
  lrwxrwxrwx    1 root     root           69 May  1 08:11 keyboard -&gt; /dev/input/by-id/usb-Cypress_WinCE_USB_Keyboard___PS2_Mouse-event-kbd
  lrwxrwxrwx    1 root     root            6 Jan  1  2000 keypad -&gt; event2
  crw-r-----    1 root     root      13,  63 Jan  1  2000 mice
  crw-r-----    1 root     root      13,  32 Jan  1  2000 mouse0
  crw-r-----    1 root     root      13,  33 Jan  1  2000 mouse1
  crw-r-----    1 root     root      13,  34 Jan  1  2000 mouse2
  crw-r-----    1 root     root      13,  35 Jan  1  2000 mouse3
  lrwxrwxrwx    1 root     root           67 May  1 08:11 touchscreen -&gt; /dev/input/by-id/usb-eGalax_Inc._USB_TouchController-event-joystick
  
  root@dm814x-evm:/dev/input/by-id# ls -l
  lrwxrwxrwx    1 root     root            9 Jan  1  2000 usb-Cypress_WinCE_USB_Keyboard___PS2_Mouse-event-kbd -&gt; ../event0
  lrwxrwxrwx    1 root     root            9 Jan  1  2000 usb-Cypress_WinCE_USB_Keyboard___PS2_Mouse-event-mouse -&gt; ../event1
  lrwxrwxrwx    1 root     root            9 Jan  1  2000 usb-Cypress_WinCE_USB_Keyboard___PS2_Mouse-mouse -&gt; ../mouse0
  lrwxrwxrwx    1 root     root            9 Jan  1  2000 usb-eGalax_Inc._USB_TouchController-event-joystick -&gt; ../event3
  lrwxrwxrwx    1 root     root            9 Jan  1  2000 usb-eGalax_Inc._USB_TouchController-event-mouse -&gt; ../event6
  lrwxrwxrwx    1 root     root            9 Jan  1  2000 usb-eGalax_Inc._USB_TouchController-joystick -&gt; ../mouse1
  lrwxrwxrwx    1 root     root            9 Jan  1  2000 usb-eGalax_Inc._USB_TouchController-mouse -&gt; ../mouse3
  </code></pre>
  
  <p>It appears to me that the touchscreen is acting as a mouse and therefore will only produce mouse events.</p>
  
  <p>This might now be beyond the scope of this forum?</p>