Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QTouchEvent instead QMouseEvent on Linux

I am trying to handle QTouchEvent from M3 touchscreen in Qt 5.9. I use Qt Finger Print example and it works fine on Windows 7 but on Ubuntu 16.04 I receive mouse events instead of touch events. Is it Qt's fault or wrong OS configuration?

What is more QTouchDevice::devices().size() always equals 0.

like image 827
Mariusz Jaskółka Avatar asked Oct 02 '17 14:10

Mariusz Jaskółka


1 Answers

I suggest you to use EventFilters to catch touch and mouse events in multiple platforms. To doing this you have to call installEventFilter in the constructor of your widget and implement the eventFilter to filter the QEvent you are looking for. For example using something like this:

bool ECGPlot::eventFilter(QObject *o, QEvent *ev) {
    bool ret = false;

    switch (ev->type ()) {
        case QEvent::TouchBegin:
            ret = true;
            break;

        case QEvent::TouchUpdate:
            ret = true;
            break;

        case QEvent::TouchEnd:
            ret = true;
            break;

        case QEvent::Wheel:
            ret = true;
            break;

        case QEvent::MouseButtonPress:
            ret = true;
            break;

        case QEvent::MouseButtonRelease:
            ret = true;
            break;

        case QEvent::MouseMove:
            ret = true;
            break;

    }

    return ret;
}
like image 109
Marcelino Avatar answered Nov 12 '22 22:11

Marcelino