My touchscreen press gives me mousePressEvent



  • Hi There,

    I am using Qt4 on linux.

    I am implementing an application for a touchscreen display and I also have a mouse and keyboard plugged in.

    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.

    (note: I re-implemented this function so that I can do this things I need)

    @
    MainWindow::mousePressEvent(QMouseEvent *ev)
    {
    // Handle mouse specific events
    }
    @

    However when I press the touchscreen I also get the same function triggered : (

    I therefore cannot distinguish between mouse clicks and touchscreen presses! - how do I get around this issue?
    I have tried looking at the event type, but its always = 2 (mouseClickEvent, but never TouchBegin or such)

    Thanks



  • If you don't receive any touch event make sure you set Qt::WA_AcceptTouchEvents attribute to your widgets.



  • MontezooM,

    I tried this, and implemented the MainWindown::filterEvent()

    However, all events (from mouse and from touchScreen) are recieved as mouse events. I never see a TOUCH_BEGIN, or TOUCH_anything... this is strange, I can't figure out why.



  • You could try some qt touch examples (e.g. fingerpaint) with your touch screen and see if TouchBegin/TouchUpdate/Touch... event is woriking. Maybe this help you define why your code don't work.



  • I have looked further into this and implemented somthing like this:

    @
    MainWindow::MainWindow(QWidget *parent)
    {
    ...
    qApp->installEventFilter(this);
    setAttribute(Qt::WA_AcceptTouchEvents);
    setAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
    }
    bool MainWindow::eventFilter(QObject *, QEvent * pEvent)
    {
    switch(pEvent->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;
    }
    @

    I found that I ALWAYS get a MouseMove event regardless of if its a touchscreen input or a mouse input.

    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:

    @
    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 -> /dev/input/by-id/usb-Cypress_WinCE_USB_Keyboard___PS2_Mouse-event-kbd
    lrwxrwxrwx 1 root root 6 Jan 1 2000 keypad -> 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 -> /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 -> ../event0
    lrwxrwxrwx    1 root     root            9 Jan  1  2000 usb-Cypress_WinCE_USB_Keyboard___PS2_Mouse-event-mouse -> ../event1
    lrwxrwxrwx    1 root     root            9 Jan  1  2000 usb-Cypress_WinCE_USB_Keyboard___PS2_Mouse-mouse -> ../mouse0
    lrwxrwxrwx    1 root     root            9 Jan  1  2000 usb-eGalax_Inc._USB_TouchController-event-joystick -> ../event3
    lrwxrwxrwx    1 root     root            9 Jan  1  2000 usb-eGalax_Inc._USB_TouchController-event-mouse -> ../event6
    lrwxrwxrwx    1 root     root            9 Jan  1  2000 usb-eGalax_Inc._USB_TouchController-joystick -> ../mouse1
    lrwxrwxrwx    1 root     root            9 Jan  1  2000 usb-eGalax_Inc._USB_TouchController-mouse -> ../mouse3
    

    @

    It appears to me that the touchscreen is acting as a mouse and therefore will only produce mouse events.

    So I think this may be an OS issue.. : (

    You have any more ideas? :o

    Thanks for your help though : )



  • You can try write some more low-level code to handle events =)

    BTW, I don't know how exactly how QtEventSystem works on other platform, but on Android (with Qt5.1) user's TouchEvent generate both QMouseEvent and QTouchEvent at the same time, so if you even had working touch event, there could be an issue to distinguish which event was received from mouse and which from touchscreen.



  • Ok, thanks very much for your help. I think at least I have a direction to investigate into!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.