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.
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With